Leafo\ScssPhp\Parser::matchString PHP Method

matchString() protected method

{@internal This is a workaround for preg_match's 250K string match limit.}}
protected matchString ( array &$m, string $delim ) : boolean
$m array Matches (passed by reference)
$delim string Delimeter
return boolean True if match; false otherwise
    protected function matchString(&$m, $delim)
    {
        $token = null;
        $end = strlen($this->buffer);
        // look for either ending delim, escape, or string interpolation
        foreach (['#{', '\\', $delim] as $lookahead) {
            $pos = strpos($this->buffer, $lookahead, $this->count);
            if ($pos !== false && $pos < $end) {
                $end = $pos;
                $token = $lookahead;
            }
        }
        if (!isset($token)) {
            return false;
        }
        $match = substr($this->buffer, $this->count, $end - $this->count);
        $m = [$match . $token, $match, $token];
        $this->count = $end + strlen($token);
        return true;
    }