public function matches(string $uri) : bool { if ($this->pattern->matches($uri)) { $this->uriParams = $this->pattern->getMatches(); foreach ($this->routes as $route) { if ($route->matches($uri)) { $this->requestHandler = $route->getRequestHandler(); $this->uriParams = array_merge($this->uriParams, $route->getUriParams()); return true; } } } return false; }
/** * @param string $pattern * @param string $other * @param array $expectedMatches * * @dataProvider regExpMatchesProvider */ public function testCanGetMatches(string $pattern, string $other, array $expectedMatches) { $regExp = new NamedRegExp($pattern); $regExp->matches($other); $this->assertEquals($expectedMatches, $regExp->getMatches()); }