protected function parseRuleString($ruleString)
    {
        $charset = $this->getCharset();

        // Remove at-rule and unnecessary white-spaces
        $ruleString = preg_replace('/^[ \r\n\t\f]*@import[ \r\n\t\f]+/i', '', $ruleString);
        $ruleString = trim($ruleString, " \r\n\t\f");

        // Remove trailing semicolon
        $ruleString = rtrim($ruleString, ";");

        $isEscaped  = false;
        $inFunction = false;

        $url = "";
        $mediaQuery = "";
        $currentPart  = "";
        for ($i = 0, $j = mb_strlen($ruleString, $charset); $i < $j; $i++) {
            $char = mb_substr($ruleString, $i, 1, $charset);
            if ($char === "\\") {
                if ($isEscaped === false) {
                    $isEscaped = true;
                } else {
                    $isEscaped = false;
                }
            } else {
                if ($char === " ") {
                    if ($isEscaped === false) {
                        if ($inFunction == false) {
                            $currentPart = trim($currentPart, " \r\n\t\f");
                            if ($currentPart !== "") {
                                if ($url === "") {
                                    $url = trim($currentPart, " \r\n\t\f");
                                } else {
                                    $mediaQuery .= trim($currentPart, " \r\n\t\f");
                                    $mediaQuery .= $char;
                                }
                                $currentPart = "";
                            }
                        }
                    } else {
                        $currentPart .= $char;
                    }
                } elseif ($isEscaped === false && $char === "(") {
                    $inFunction = true;
                    $currentPart .= $char;
                } elseif ($isEscaped === false && $char === ")") {
                    $inFunction = false;
                    $currentPart .= $char;
                } else {
                    $currentPart .= $char;
                }
            }

            // Reset escaped flag
            if ($isEscaped === true && $char !== "\\") {
                $isEscaped = false;
            }
        }
        if ($currentPart !== "") {
            $currentPart = trim($currentPart, " \r\n\t\f");
            if ($currentPart !== "") {
                if ($url === "") {
                    $url = trim($currentPart, " \r\n\t\f");
                } else {
                    $mediaQuery .= trim($currentPart, " \r\n\t\f");
                }
            }
        }

        // Get URL value
        $url = Url::extractUrl($url);
        $this->setUrl($url);

        // Process media query
        $mediaRule = new MediaRule($mediaQuery);
        $this->setQueries($mediaRule->getQueries());
    }