From 6ad39e3ba64e518bcdba1fc32b6247375be39a8a Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: shared code in traits for common features for groups --- src/Router.php | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'src/Router.php') diff --git a/src/Router.php b/src/Router.php index b219651..d6b255a 100644 --- a/src/Router.php +++ b/src/Router.php @@ -12,6 +12,9 @@ use Psr\Http\Message\ResponseInterface; class Router { + use Concerns\CreatesRoutes; + use Concerns\CreatesGroups; + private PathSegment $root; private Strategy $strategy; @@ -24,6 +27,16 @@ class Router $this->strategy = new BasicStrategy(); } + private function getRouter(): self + { + return $this; + } + + private function getGroup(): null + { + return null; + } + public function getStrategy(): Strategy { return $this->strategy; @@ -136,36 +149,6 @@ class Router return new RouteDefinition($this, $route); } - public function get(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Get, $path, $handler); - } - - public function post(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Post, $path, $handler); - } - - public function put(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Put, $path, $handler); - } - - public function patch(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Patch, $path, $handler); - } - - public function delete(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Delete, $path, $handler); - } - - public function any(string $path, callable $handler): RouteDefinition - { - return $this->make(HttpMethod::Any, $path, $handler); - } - public function addNamedRoute(string $name, Route $route): void { $this->namedRoutes[$name] = $route; -- cgit v1.2.3