From 72767b74e81b1d3de0103d14a0219730ebed13ae Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Sat, 9 May 2015 17:56:13 -0400 Subject: [PATCH] Rename MethodMap::setMethod to ::register --- src/Routing/MethodMap.php | 2 +- src/Routing/MethodMapInterface.php | 2 +- src/Routing/RouteMap.php | 4 +-- src/Routing/RouteMapInterface.php | 2 +- src/Routing/Router.php | 2 +- test/tests/unit/Routing/MethodMapTest.php | 30 +++++++++++------------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Routing/MethodMap.php b/src/Routing/MethodMap.php index cb8ea23..960f8c4 100644 --- a/src/Routing/MethodMap.php +++ b/src/Routing/MethodMap.php @@ -41,7 +41,7 @@ class MethodMap implements MiddlewareInterface, MethodMapInterface * @param string $method * @param mixed $middleware */ - public function setMethod($method, $middleware) + public function register($method, $middleware) { $methods = explode(",", $method); $methods = array_map("trim", $methods); diff --git a/src/Routing/MethodMapInterface.php b/src/Routing/MethodMapInterface.php index 987be82..3392f0a 100644 --- a/src/Routing/MethodMapInterface.php +++ b/src/Routing/MethodMapInterface.php @@ -26,5 +26,5 @@ interface MethodMapInterface extends MiddlewareInterface * @param string $method * @param mixed $middleware */ - public function setMethod($method, $middleware); + public function register($method, $middleware); } diff --git a/src/Routing/RouteMap.php b/src/Routing/RouteMap.php index 9636835..d4efe37 100644 --- a/src/Routing/RouteMap.php +++ b/src/Routing/RouteMap.php @@ -37,7 +37,7 @@ class RouteMap implements RouteMapInterface * - A single verb ("GET"), * - A comma-separated list of verbs ("GET,PUT,DELETE") * - "*" to indicate any method. - * @see MethodMapInterface::setMethod + * @see MethodMapInterface::register * * $target may be: * - An exact path (e.g., "/path/") @@ -60,7 +60,7 @@ class RouteMap implements RouteMapInterface public function add($method, $target, $middleware) { $route = $this->getRouteForTarget($target); - $route->getMethodMap()->setMethod($method, $middleware); + $route->getMethodMap()->register($method, $middleware); } public function dispatch(ServerRequestInterface $request, ResponseInterface &$response) diff --git a/src/Routing/RouteMapInterface.php b/src/Routing/RouteMapInterface.php index cfbc527..5e33792 100644 --- a/src/Routing/RouteMapInterface.php +++ b/src/Routing/RouteMapInterface.php @@ -11,7 +11,7 @@ interface RouteMapInterface extends MiddlewareInterface * - A single verb ("GET"), * - A comma-separated list of verbs ("GET,PUT,DELETE") * - "*" to indicate any method. - * @see MethodMapInterface::setMethod + * @see MethodMapInterface::register * * $target may be: * - An exact path (e.g., "/path/") diff --git a/src/Routing/Router.php b/src/Routing/Router.php index ba3a4b9..693819a 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -70,7 +70,7 @@ class Router implements MiddlewareInterface, RouteMapInterface * - A single verb ("GET"), * - A comma-separated list of verbs ("GET,PUT,DELETE") * - "*" to indicate any method. - * @see MethodMapInterface::setMethod + * @see MethodMapInterface::register * * $target may be: * - An exact path (e.g., "/path/") diff --git a/test/tests/unit/Routing/MethodMapTest.php b/test/tests/unit/Routing/MethodMapTest.php index bc4c6a0..df2f1a3 100644 --- a/test/tests/unit/Routing/MethodMapTest.php +++ b/test/tests/unit/Routing/MethodMapTest.php @@ -43,14 +43,14 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase * @covers ::dispatch * @covers ::dispatchMiddleware * @covers ::getDispatcher - * @covers ::setMethod + * @covers ::register */ public function testDispatchesMiddlewareWithMatchingMethod() { $this->request->getMethod()->willReturn("GET"); $map = new MethodMap(); - $map->setMethod("GET", $this->middleware->reveal()); + $map->register("GET", $this->middleware->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->middleware->dispatch($this->request->reveal(), $this->response->reveal(), $this->next)->shouldHaveBeenCalled(); @@ -70,8 +70,8 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $middlewareLower->dispatch(Argument::cetera())->willReturn(); $map = new MethodMap(); - $map->setMethod("GET", $middlewareUpper->reveal()); - $map->setMethod("get", $middlewareLower->reveal()); + $map->register("GET", $middlewareUpper->reveal()); + $map->register("get", $middlewareLower->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $middlewareLower->dispatch($this->request->reveal(), $this->response->reveal(), $this->next)->shouldHaveBeenCalled(); @@ -81,14 +81,14 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase * @covers ::dispatch * @covers ::dispatchMiddleware * @covers ::getDispatcher - * @covers ::setMethod + * @covers ::register */ public function testDispatchesWildcardMiddlewareWithNonMatchingMethod() { $this->request->getMethod()->willReturn("GET"); $map = new MethodMap(); - $map->setMethod("*", $this->middleware->reveal()); + $map->register("*", $this->middleware->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->middleware->dispatch($this->request->reveal(), $this->response->reveal(), $this->next)->shouldHaveBeenCalled(); @@ -102,19 +102,19 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $this->request->getMethod()->willReturn("HEAD"); $map = new MethodMap(); - $map->setMethod("GET", $this->middleware->reveal()); + $map->register("GET", $this->middleware->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->middleware->dispatch($this->request->reveal(), $this->response->reveal(), $this->next)->shouldHaveBeenCalled(); } /* - * @covers ::setMethod + * @covers ::register */ public function testRegistersMiddlewareForMultipleMethods() { $map = new MethodMap(); - $map->setMethod("GET,POST", $this->middleware->reveal()); + $map->register("GET,POST", $this->middleware->reveal()); $this->request->getMethod()->willReturn("GET"); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); @@ -130,8 +130,8 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $this->request->getMethod()->willReturn("POST"); $map = new MethodMap(); - $map->setMethod("POST", $this->middleware->reveal()); - $map->setMethod("POST", null); + $map->register("POST", $this->middleware->reveal()); + $map->register("POST", null); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->response->withStatus(405)->shouldHaveBeenCalled(); @@ -147,7 +147,7 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $this->request->getMethod()->willReturn("OPTIONS"); $map = new MethodMap(); - $map->setMethod("GET", $this->middleware->reveal()); + $map->register("GET", $this->middleware->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->response->withStatus(200)->shouldHaveBeenCalled(); @@ -165,7 +165,7 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $map = new MethodMap(); foreach ($methodsDeclared as $method) { - $map->setMethod($method, $this->middleware->reveal()); + $map->register($method, $this->middleware->reveal()); } $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); @@ -191,7 +191,7 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $this->request->getMethod()->willReturn("POST"); $map = new MethodMap(); - $map->setMethod("GET", $this->middleware->reveal()); + $map->register("GET", $this->middleware->reveal()); $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next); $this->response->withStatus(405)->shouldHaveBeenCalled(); @@ -209,7 +209,7 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase $map = new MethodMap(); foreach ($methodsDeclared as $method) { - $map->setMethod($method, $this->middleware->reveal()); + $map->register($method, $this->middleware->reveal()); } $map->dispatch($this->request->reveal(), $this->response->reveal(), $this->next);