private function ensureValidImportAndReplace (array $matches, callable $contentReplaceFunction) : string
    {
        $path = $matches["path"];
        $openingQuote = substr($matches["path"], 0, 1);
        $closingQuote = \substr($matches["path"], -1);
        $usedQuotes = "";

        // check if quoted and whether valid quoted
        if ($openingQuote === "'" || $openingQuote === '"')
        {
            if ($openingQuote !== $closingQuote)
            {
                // looks like invalid CSS, as there is a leading quote, but no closing one, so bail
                return $matches[0];
            }

            // strip quotes from path
            $path = \substr($path, 1, -1);
            $usedQuotes = $openingQuote;
        }

        $path = $contentReplaceFunction($path);
        return "url({$usedQuotes}{$path}{$usedQuotes})";
    }
private function ensureValidImportAndReplace (array $matches, callable $contentReplaceFunction) : string
    {
        $path = $matches["path"];
        $openingQuote = substr($matches["path"], 0, 1);
        $closingQuote = \substr($matches["path"], -1);
        $usedQuotes = "";

        // check if quoted and whether valid quoted
        if ($openingQuote === "'" || $openingQuote === '"')
        {
            if ($openingQuote !== $closingQuote)
            {
                // looks like invalid CSS, as there is a leading quote, but no closing one, so bail
                return $matches[0];
            }

            // strip quotes from path
            $path = \substr($path, 1, -1);
            $usedQuotes = $openingQuote;
        }

        $path = $contentReplaceFunction($path);
        return "url({$usedQuotes}{$path}{$usedQuotes})";
    }
private function ensureValidImportAndReplace ( array $ matches , callable $ contentReplaceFunction ) : string { $ path = $ matches [ "path" ] ; $ openingQuote = substr ( $ matches [ "path" ] , 0 , 1 ) ; $ closingQuote = \ substr ( $ matches [ "path" ] , - 1 ) ; $ usedQuotes = "" ; // check if quoted and whether valid quoted if ( $ openingQuote === "'" || $ openingQuote === '"' ) { if ( $ openingQuote !== $ closingQuote ) { // looks like invalid CSS, as there is a leading quote, but no closing one, so bail return $ matches [ 0 ] ; } // strip quotes from path $ path = \ substr ( $ path , 1 , - 1 ) ; $ usedQuotes = $ openingQuote ; } $ path = $ contentReplaceFunction ( $ path ) ; return "url({$usedQuotes}{$path}{$usedQuotes})" ; }
Replaces all valid imports with the result of the content replace function

@param array    $matches
@param callable $contentReplaceFunction
@return string
Replaces all valid imports with the result of the content replace function