PhpCss\Parser::read PHP Method

read() protected method

This method tries to match the current token list against all of the provided tokens. If a match is found it is removed from the token list and returned. If no match can be found a PhpCssParserException will thrown indicating what has been expected and what was found. The $expectedTokens parameter may be an array of tokens or a scalar value, which is handled the same way an array with only one entry would be. The special Token Scanner\Token::ANY may be used to indicate everything is valid and may be matched. However if it is used no other token may be specified, which does not make any sense, anyway.
protected read ( array | integer | string $expectedTokens ) : Token
$expectedTokens array | integer | string
return PhpCss\Scanner\Token
    protected function read($expectedTokens)
    {
        // Allow scalar token values for better readability
        if (!is_array($expectedTokens)) {
            return $this->read(array($expectedTokens));
        }
        foreach ($expectedTokens as $token) {
            if ($this->matchToken(0, $token)) {
                return array_shift($this->_tokens);
            }
        }
        // None of the given tokens matched
        throw $this->handleMismatch($expectedTokens);
    }