Пример #1
0
 public function testCompile()
 {
     $expected = '#foo.*bar#u';
     $patternValue = 'foo*bar';
     $patternTokens = [[Tokenizer::T_WORD, 1, 'foo'], [Tokenizer::T_WILDCARD_MULTI, 1, '*'], [Tokenizer::T_WORD, 1, 'bar']];
     $this->tokenizer->expects($this->once())->method('parse')->with($patternValue)->will($this->returnValue($patternTokens));
     $this->builder->expects($this->once())->method('createFromTokens')->with($patternTokens)->will($this->returnValue($expected));
     $result = $this->compiler->compile($patternValue);
     $this->assertEquals($expected, $result);
 }
Пример #2
0
 /**
  * @param string $pattern
  * @return string
  */
 public function compile($pattern)
 {
     $tokens = $this->tokenizer->parse($pattern);
     $regex = $this->builder->createFromTokens($tokens);
     return $regex;
 }