Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\ReferenceLexer::lex PHP Метод

lex() публичный Метод

public lex ( string $value ) : array
$value string
Результат array
    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))];
            }
        }
        throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($value);
    }

Usage Example

Пример #1
0
 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\LexException
  * @expectedExceptionMessage Could not lex the value "foo".
  */
 public function testThrowsAnExceptionIfNoMatchingPatternFound()
 {
     $this->lexer->lex('foo');
 }
ReferenceLexer