public function splitIntoSeparateMediaQueries($rulesString)
    {
        // Intelligently break up rules, preserving mediaquery context and such

        $mediaQuerySelector = '/@media[^{]+\{([\s\S]+?\})\s*\}/';
        $mediaQueryMatches = [];
        preg_match_all($mediaQuerySelector, $rulesString, $mediaQueryMatches);

        $remainingRuleSet = $rulesString;

        $queryParts = [];
        foreach (reset($mediaQueryMatches) as $mediaQueryMatch) {
            $tokenisedRules = explode($mediaQueryMatch, $remainingRuleSet);

            $queryParts[] = reset($tokenisedRules);
            $queryParts[] = $mediaQueryMatch;

            if (count($tokenisedRules) === 2) {
                $remainingRuleSet = end($tokenisedRules);
            } else {
                $remainingRuleSet = '';
            }
        }

        if (!empty($remainingRuleSet)) {
            $queryParts[] = $remainingRuleSet;
        }

        $indexedRules = [];

        foreach ($queryParts as $part) {
            if (strpos($part, '@media') === false) {
                $indexedRules[][''] = (array)explode('}', $part);
                continue;
            }

            $mediaQueryString = substr($part, 0, strpos($part, '{'));

            // No need for print css
            if (trim($mediaQueryString) === '@media print') {
                continue;
            }

            $mediaQueryRules = substr($part, strpos($part, '{') + 1);

            $mediaQueryRules = substr($mediaQueryRules, 0, -1);


            $indexedRules[][$mediaQueryString] = (array)explode('}', $mediaQueryRules);
        }

        return $indexedRules;
    }