Automattic\WooCommerce\Vendor\Sabberworm\CSS\RuleSet
RuleSet::addRule
Method of the class: RuleSet{}
No Hooks.
Returns
null. Nothing (null).
Usage
$RuleSet = new RuleSet(); $RuleSet->addRule( $oRule, $oSibling );
RuleSet::addRule() RuleSet::addRule code WC 10.8.1
public function addRule(Rule $oRule, $oSibling = null)
{
$sRule = $oRule->getRule();
if (!isset($this->aRules[$sRule])) {
$this->aRules[$sRule] = [];
}
$iPosition = count($this->aRules[$sRule]);
if ($oSibling !== null) {
$iSiblingPos = array_search($oSibling, $this->aRules[$sRule], true);
if ($iSiblingPos !== false) {
$iPosition = $iSiblingPos;
$oRule->setPosition($oSibling->getLineNo(), $oSibling->getColNo() - 1);
}
}
if ($oRule->getLineNumber() === null) {
//this node is added manually, give it the next best line
$columnNumber = $oRule->getColNo();
$rules = $this->getRules();
$pos = count($rules);
if ($pos > 0) {
$last = $rules[$pos - 1];
$oRule->setPosition($last->getLineNo() + 1, $columnNumber);
} else {
$oRule->setPosition(1, $columnNumber);
}
} elseif ($oRule->getColumnNumber() === null) {
$oRule->setPosition($oRule->getLineNumber(), 0);
}
array_splice($this->aRules[$sRule], $iPosition, 0, [$oRule]);
}