diff --git a/src/Regex.php b/src/Regex.php index 45aeb3c5..c0792077 100644 --- a/src/Regex.php +++ b/src/Regex.php @@ -52,6 +52,8 @@ class Regex * * @param string $path The requested URL path. * + * @param string $basepath A basepath to prefix to the route path. + * * @return bool * */ diff --git a/src/Route.php b/src/Route.php index a64ef2d2..62000ab2 100644 --- a/src/Route.php +++ b/src/Route.php @@ -238,6 +238,8 @@ public function __isset($key) * @param array $server A copy of $_SERVER so that this Route can check * against the server values. * + * @param string $basepath A basepath to prefix to the route path. + * * @return bool * */ @@ -263,6 +265,8 @@ public function isMatch($path, array $server, $basepath = null) * @param array $server A copy of $_SERVER so that this Route can check * against the server values. * + * @param string $basepath A basepath to prefix to the route path. + * * @return bool * */ @@ -391,6 +395,8 @@ protected function serverIsSecure($server) * * @param string $path The path to match against. * + * @param string $basepath A basepath to prefix to the route path. + * * @return bool True on a match, false if not. * */ diff --git a/src/Router.php b/src/Router.php index 9015ee47..a5a832db 100644 --- a/src/Router.php +++ b/src/Router.php @@ -72,6 +72,13 @@ class Router */ protected $failed_route = null; + /** + * + * A basepath to all routes. + * + * @var string + * + */ protected $basepath; /** @@ -82,6 +89,8 @@ class Router * * @param Generator $generator A URL path generator. * + * @param string $basepath A basepath to to all routes. + * */ public function __construct( RouteCollection $routes, diff --git a/src/RouterFactory.php b/src/RouterFactory.php index dca8f47d..f8cb3e83 100644 --- a/src/RouterFactory.php +++ b/src/RouterFactory.php @@ -17,6 +17,27 @@ */ class RouterFactory { + /** + * + * A basepath to all routes. + * + * @var string + * + */ + protected $basepath; + + /** + * + * Constructor. + * + * @param string $basepath A basepath to to all routes. + * + */ + public function __construct($basepath = null) + { + $this->basepath = $basepath; + } + /** * * Returns a new Router instance. @@ -24,12 +45,12 @@ class RouterFactory * @return Router * */ - public function newInstance($basepath = null) + public function newInstance() { return new Router( new RouteCollection(new RouteFactory), new Generator, - $basepath + $this->basepath ); } } diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 3aea2f3c..8ac3ca51 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -13,8 +13,8 @@ protected function setUp() protected function newRouter($basepath = null) { - $factory = new RouterFactory; - return $factory->newInstance($basepath); + $factory = new RouterFactory($basepath); + return $factory->newInstance(); } protected function assertIsRoute($actual)