Esempio n. 1
0
 /**
  * Replace placeholders with type pattern regular expressions
  * before replacement: "/users/__PLACEHOLDER0__/active"
  * after replacement:  "/^\/users\/(\-?[0-9]*)\/active$/"
  *
  * @param $patternRegex
  * @return string
  * @throws \Coduo\PHPMatcher\Exception\UnknownTypeException
  */
 private function replacePlaceholderWithPatternRegexes($patternRegex, array $patternsReplacedWithRegex)
 {
     $regexConverter = new RegexConverter();
     foreach ($patternsReplacedWithRegex as $index => $typePattern) {
         $patternRegex = str_replace(sprintf(self::PATTERN_REGEXP_PLACEHOLDER_TEMPLATE, $index), $regexConverter->toRegex($typePattern), $patternRegex);
     }
     return $patternRegex;
 }
Esempio n. 2
0
 /**
  * @expectedException \Coduo\PHPMatcher\Exception\UnknownTypeException
  */
 public function test_convert_unknown_type()
 {
     $this->converter->toRegex(new TypePattern("not_a_type"));
 }