diff --git a/src/Routing/Route/TemplateRoute.php b/src/Routing/Route/TemplateRoute.php index 3649633..8b71790 100644 --- a/src/Routing/Route/TemplateRoute.php +++ b/src/Routing/Route/TemplateRoute.php @@ -29,7 +29,7 @@ class TemplateRoute extends Route * Examines a request target to see if it is a match for the route. * * @param string $requestTarget - * @return boolean + * @return bool */ public function matchesRequestTarget($requestTarget) { @@ -49,9 +49,16 @@ class TemplateRoute extends Route return false; } + /** + * @param $requestTarget + * @return bool + */ private function matchesStartOfRequestTarget($requestTarget) { $firstVarPos = strpos($this->target, "{"); + if ($firstVarPos === false) { + return $requestTarget === $this->target; + } return (substr($requestTarget, 0, $firstVarPos) === substr($this->target, 0, $firstVarPos)); } diff --git a/src/Routing/Router.php b/src/Routing/Router.php index 4ac8164..b836538 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -12,7 +12,7 @@ use WellRESTed\Routing\Route\RouteInterface; class Router { - /** @var string attribute name for matched path variables */ + /** @var string|null Attribute name for matched path variables */ private $pathVariablesAttributeName; /** @var DispatcherInterface */ private $dispatcher; @@ -42,7 +42,7 @@ class Router * stored with the name. The value will be an array containing all of the * path variables. * - * @param DispatcherInterface $dispatcher + * @param DispatcherInterface|null $dispatcher * Instance to use for dispatching middleware and handlers. * @param string|null $pathVariablesAttributeName * Attribute name for matched path variables. A null value sets