Latte\Parser::match PHP Method

match() private method

Matches next token.
private match ( $re ) : array
return array
    private function match($re)
    {
        if (!preg_match($re, $this->input, $matches, PREG_OFFSET_CAPTURE, $this->offset)) {
            if (preg_last_error()) {
                throw new RegexpException(NULL, preg_last_error());
            }
            return [];
        }
        $value = substr($this->input, $this->offset, $matches[0][1] - $this->offset);
        if ($value !== '') {
            $this->addToken(Token::TEXT, $value);
        }
        $this->offset = $matches[0][1] + strlen($matches[0][0]);
        foreach ($matches as $k => $v) {
            $matches[$k] = $v[0];
        }
        return $matches;
    }