diff --git a/src/Router.php b/src/Router.php index f2a566e..ecf083a 100644 --- a/src/Router.php +++ b/src/Router.php @@ -196,7 +196,7 @@ class Router foreach ($router->getMethods() as $name => $method) { $middlewares = $middleware->get($method->getClass(), $method->getMethod()); - $router->setMethod($name, new HttpRequestHandler($middlewares, $method)); + $router->setHttpHandler($name, new HttpRequestHandler($middlewares, $method)); } } diff --git a/src/RouterCollector.php b/src/RouterCollector.php index 92f353d..af0e493 100644 --- a/src/RouterCollector.php +++ b/src/RouterCollector.php @@ -47,6 +47,12 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate private array $methods = []; + /** + * @var array + */ + protected array $httpHandler = []; + + /** * @var Handler */ @@ -80,9 +86,9 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate * @param HttpRequestHandler $handler * @return void */ - public function setMethod(string $method, HttpRequestHandler $handler): void + public function setHttpHandler(string $method, HttpRequestHandler $handler): void { - $this->methods[$method] = $handler; + $this->httpHandler[$method] = $handler; } @@ -237,7 +243,7 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate */ public function query(string $path, string $method): HttpRequestHandler { - return $this->methods[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found); + return $this->httpHandler[$method . '_' . $path] ?? new HttpRequestHandler([], $this->found); }