public static createForInvalidExpressionLanguageToken ( string $value ) : InvalidArgumentException | ||
$value | string | |
return | InvalidArgumentException |
public function testTestCreateForInvalidExpressionLanguageToken() { $exception = InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken('foo'); $this->assertEquals('Invalid token "foo" found.', $exception->getMessage()); $this->assertEquals(0, $exception->getCode()); $this->assertNull($exception->getPrevious()); }
/** * {@inheritdoc} * * @throws LexException */ public function lex(string $value) : array { foreach (self::PATTERNS as $pattern => $tokenTypeConstant) { if (1 === preg_match($pattern, $value, $matches)) { if (null === $tokenTypeConstant) { throw InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken($value); } return [new Token($matches[0], new TokenType($tokenTypeConstant))]; } } return $this->lexer->lex($value); }
/** * @param LexerInterface $referenceLexer * @param string $valueFragment * * @throws LexException * * @return Token[] */ private function lexFragment(LexerInterface $referenceLexer, string $valueFragment) : array { foreach (self::PATTERNS as $pattern => $tokenTypeConstant) { if (1 === preg_match($pattern, $valueFragment, $matches)) { if (null === $tokenTypeConstant) { throw InvalidArgumentExceptionFactory::createForInvalidExpressionLanguageToken($valueFragment); } $match = $matches[1]; if (self::REFERENCE_LEXER === $tokenTypeConstant) { return $referenceLexer->lex($match); } return [new Token($match, new TokenType($tokenTypeConstant))]; } } throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($valueFragment); }