diff --git a/src/pjdietz/WellRESTed/Interfaces/Routes/StaticRouteInterface.php b/src/pjdietz/WellRESTed/Interfaces/Routes/StaticRouteInterface.php index b3a008f..0e83e1e 100644 --- a/src/pjdietz/WellRESTed/Interfaces/Routes/StaticRouteInterface.php +++ b/src/pjdietz/WellRESTed/Interfaces/Routes/StaticRouteInterface.php @@ -1,10 +1,10 @@ - * @copyright Copyright 2014 by PJ Dietz + * @copyright Copyright 2015 by PJ Dietz * @license MIT */ diff --git a/src/pjdietz/WellRESTed/Router.php b/src/pjdietz/WellRESTed/Router.php index c221264..b54ac4d 100644 --- a/src/pjdietz/WellRESTed/Router.php +++ b/src/pjdietz/WellRESTed/Router.php @@ -99,7 +99,7 @@ class Router implements HandlerInterface * A route for an exact match to a path. * * @param string|array $paths Path component of the URI or a list of paths - * @param string $handler Fully qualified name to an autoloadable handler class. + * @param string $handler Fully qualified name to an autoloadable handler class */ public function setStaticRoute($paths, $handler) { @@ -180,10 +180,7 @@ class Router implements HandlerInterface // First check if there is a handler for this exact path. $handler = $this->getStaticHandler($path); if ($handler) { - $reponse = $this->tryResponse($handler, $request, $args); - if ($reponse) { - return $reponse; - } + return $this->tryResponse($handler, $request, $args); } // Try each of the routes. diff --git a/src/pjdietz/WellRESTed/Routes/StaticRoute.php b/src/pjdietz/WellRESTed/Routes/StaticRoute.php index 67e1af8..112c4f0 100644 --- a/src/pjdietz/WellRESTed/Routes/StaticRoute.php +++ b/src/pjdietz/WellRESTed/Routes/StaticRoute.php @@ -11,7 +11,6 @@ namespace pjdietz\WellRESTed\Routes; use InvalidArgumentException; -use pjdietz\WellRESTed\Interfaces\HandlerInterface; use pjdietz\WellRESTed\Interfaces\RequestInterface; use pjdietz\WellRESTed\Interfaces\Routes\StaticRouteInterface; @@ -21,24 +20,24 @@ use pjdietz\WellRESTed\Interfaces\Routes\StaticRouteInterface; class StaticRoute extends BaseRoute implements StaticRouteInterface { /** @var array List of static URI paths */ - protected $paths; + private $paths; /** * Create a new StaticRoute for a given path or paths and a handler class. * - * @param string|array $paths Path or list of paths the request must match + * @param string|array $prefixes Path or list of paths the request must match * @param string $targetClassName Fully qualified name to an autoloadable handler class. * @throws \InvalidArgumentException */ - public function __construct($paths, $targetClassName) + public function __construct($prefixes, $targetClassName) { parent::__construct($targetClassName); - if (is_string($paths)) { - $this->paths = array($paths); - } elseif (is_array($paths)) { - $this->paths = $paths; + if (is_string($prefixes)) { + $this->paths = array($prefixes); + } elseif (is_array($prefixes)) { + $this->paths = $prefixes; } else { - throw new InvalidArgumentException("$paths must be a string or array of string"); + throw new InvalidArgumentException("$prefixes must be a string or array of string"); } } diff --git a/test/RouterTest.php b/test/RouterTest.php index 5b4ceaf..afd9c0a 100644 --- a/test/RouterTest.php +++ b/test/RouterTest.php @@ -48,20 +48,6 @@ class RouterTest extends \PHPUnit_Framework_TestCase $this->assertEquals(200, $resp->getStatusCode()); } - public function testTryRoutesAfterNullStaticRoute() - { - $mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface'); - $mockRequest->expects($this->any()) - ->method('getPath') - ->will($this->returnValue("/cat/")); - - $router = new Router(); - $router->setStaticRoute("/cat/", __NAMESPACE__ . '\\NullResponseHandler'); - $router->addRoute(new TemplateRoute("/cat/*", __NAMESPACE__ . '\\RouterTestHandler')); - $resp = $router->getResponse($mockRequest); - $this->assertEquals(200, $resp->getStatusCode()); - } - public function testRespondWithDefaultErrorForException() { $mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface'); @@ -362,11 +348,3 @@ class InjectionHandler implements HandlerInterface return $response; } } - -class NullResponseHandler implements HandlerInterface -{ - public function getResponse(RequestInterface $request, array $args = null) - { - return null; - } -}