Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\TokenParser\TokenParserRegistry::parse PHP Method

parse() public method

public parse ( Token $token )
$token Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Token
    public function parse(Token $token)
    {
        foreach ($this->parsers as $parser) {
            if ($parser->canParse($token)) {
                return $parser->parse($token);
            }
        }
        throw ExpressionLanguageExceptionFactory::createForNoParserFoundForToken($token);
    }

Usage Example

Example #1
0
 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\ParserNotFoundException
  * @expectedExceptionMessage No suitable token parser found to handle the token "foo" (type: STRING_TYPE).
  */
 public function testThrowsAnExceptionIfNoSuitableParserIsFound()
 {
     $registry = new TokenParserRegistry([]);
     $registry->parse(new Token('foo', new TokenType(TokenType::STRING_TYPE)));
 }