/** * @test */ public function pathSetByConstructorGetsReturnedAsIs() { $route = new Route('GET', '/info'); $this->assertSame('/info', $route->getPath()); }
/** * {@inheritdoc} */ protected function getPathMatcherForRoute(Route $route) { $pathMatcher = preg_replace('#\\[:(.+?)\\]#i', '(?P<$1>.+?)/?', $route->getPath()); return sprintf('#^%s$#i', $pathMatcher); }
/** * Validates given route for configuration correctness and throws \ConfigurationException * if any required configuration is missing. Returns true if everything's fine * * @param Route $route * @throws \ConfigurationException */ protected function validateRoute(Route $route) { if (null === $route->getPath()) { throw new \ConfigurationException('Route must have defined a path'); } if (null === $route->getTarget()) { throw new \ConfigurationException('Route must have defined a target'); } if (0 === count($route->getMethods())) { throw new \ConfigurationException('Route must at least accept one request method'); } if (!is_string($route->getTarget()) and null === $route->getName()) { throw new \ConfigurationException('If defined route target is not a string a name has to be set'); } }