Automattic\WooCommerce\Vendor\Sabberworm\CSS\RuleSet
RuleSet::getRulesAssoc
Returns all rules matching the given pattern and returns them in an associative array with the rule’s name as keys. This method exists mainly for backwards-compatibility and is really only partially useful.
Note: This method loses some information: Calling this (with an argument of background-) on a declaration block like { background-color: green; background-color; rgba(0, 127, 0, 0.7); } will only yield an associative array containing the rgba-valued rule while getRules() would yield an indexed array containing both.
Method of the class: RuleSet{}
No Hooks.
Returns
Array
Usage
$RuleSet = new RuleSet(); $RuleSet->getRulesAssoc( $mRule );
- $mRule(Rule|string|null)
$mRulePattern to search for. If null, returns all rules. If the pattern ends with a dash, all rules starting with the pattern are returned as well as one matching the pattern with the dash excluded. Passing aRulefor this parameter is deprecated in version 8.9.0, and will not work from v9.0. CallgetRulesAssoc($rule->getRule())instead.
Default:null
RuleSet::getRulesAssoc() RuleSet::getRulesAssoc code WC 10.8.1
public function getRulesAssoc($mRule = null)
{
/** @var array<string, Rule> $aResult */
$aResult = [];
foreach ($this->getRules($mRule) as $oRule) {
$aResult[$oRule->getRule()] = $oRule;
}
return $aResult;
}