private function getCssRuleMatches($css)
    {
        $ruleMatches = [];

        $splitCss = $this->splitCssAndMediaQuery($css);
        foreach ($splitCss as $cssPart) {
            // process each part for selectors and definitions
            \preg_match_all('/(?:^|[\\s^{}]*)([^{]+){([^}]*)}/mi', $cssPart['css'], $matches, PREG_SET_ORDER);

            /** @var string[][] $matches */
            foreach ($matches as $cssRule) {
                $ruleMatches[] = [
                    'media' => $cssPart['media'],
                    'selectors' => $cssRule[1],
                    'declarations' => $cssRule[2],
                ];
            }
        }

        return $ruleMatches;
    }
private function getCssRuleMatches($css)
    {
        $ruleMatches = [];

        $splitCss = $this->splitCssAndMediaQuery($css);
        foreach ($splitCss as $cssPart) {
            // process each part for selectors and definitions
            \preg_match_all('/(?:^|[\\s^{}]*)([^{]+){([^}]*)}/mi', $cssPart['css'], $matches, PREG_SET_ORDER);

            /** @var string[][] $matches */
            foreach ($matches as $cssRule) {
                $ruleMatches[] = [
                    'media' => $cssPart['media'],
                    'selectors' => $cssRule[1],
                    'declarations' => $cssRule[2],
                ];
            }
        }

        return $ruleMatches;
    }
private function getCssRuleMatches ( $ css ) { $ ruleMatches = [ ] ; $ splitCss = $ this -> splitCssAndMediaQuery ( $ css ) ; foreach ( $ splitCss as $ cssPart ) { // process each part for selectors and definitions \ preg_match_all ( '/(?:^|[\\s^{}]*)([^{]+){([^}]*)}/mi' , $ cssPart [ 'css' ] , $ matches , PREG_SET_ORDER ) ; /** @var string[][] $matches */ foreach ( $ matches as $ cssRule ) { $ ruleMatches [ ] = [ 'media' => $ cssPart [ 'media' ] , 'selectors' => $ cssRule [ 1 ] , 'declarations' => $ cssRule [ 2 ] , ] ; } } return $ ruleMatches ; }
Parses a string of CSS into the media query, selectors and declarations for each ruleset in order.

@param string $css

@return string[][] Array of string sub-arrays with the keys
"media" (the media query string, e.g. "@media screen and (max-width: 480px)",
or an empty string if not from an `@media` rule),
"selectors" (the CSS selector(s), e.g., "*" or "h1, h2"),
"declarations" (the semicolon-separated CSS declarations for that/those selector(s),
e.g., "color: red; height: 4px;"),
Parses a string of CSS into the media query selectors and declarations for each ruleset in order .