/** * {@inheritdoc} */ protected function getPathMatcherForRoute(Route $route) { $pathMatcher = preg_replace('#\\[:(.+?)\\]#i', '(?P<$1>.+?)/?', $route->getPath()); return sprintf('#^%s$#i', $pathMatcher); }
/** * @test * @expectedException \ConfigurationException */ public function throwsAnExceptionIfTargetIsCallableAndAddedRouteHasNoNameDefined() { $this->router->addRoute(Route::get('/something')->to(function () { // do nothing })); }
/** * @test */ public function addingMatcherIsImmutable() { $matcher = $this->getMock(Matcher::class); $route = Route::create('/user/[:id]'); $route2 = $route->ifMatches('id', $matcher); $this->assertInstanceOf(Route::class, $route2); $this->assertNotEquals($route->getMatchers(), $route2->getMatchers()); }
/** * Returns the identifier string for given route. * * @param Route $route * @return string */ protected function getRouteIdentifier(Route $route) : string { return empty($route->getName()) ? $route->getTarget() : $route->getName(); }