diff --git a/src/SegmentRouter.php b/src/SegmentRouter.php index 6974837..f3424cd 100644 --- a/src/SegmentRouter.php +++ b/src/SegmentRouter.php @@ -2,10 +2,8 @@ namespace Sharkk\Router; -class SegmentRouter implements RouterInterface +trait SegmentRouterTrait { - private array $routes = []; - /** * Add a route to the route tree. The route must be a URI path, and contain dynamic segments * using a colon prefix. (:id, :slug, etc) @@ -172,3 +170,23 @@ class SegmentRouter implements RouterInterface return $this->add('HEAD', $route, $handler); } } + +interface SegmentRouterInterface extends RouterInterface +{ + //private function addNode(array &$node, array $segments, string $method, callable $handler): void; + public function clear(): RouterInterface; + public function dump(): array; + public function get(string $route, callable $handler): RouterInterface; + public function post(string $route, callable $handler): RouterInterface; + public function put(string $route, callable $handler): RouterInterface; + public function patch(string $route, callable $handler): RouterInterface; + public function delete(string $route, callable $handler): RouterInterface; + public function head(string $route, callable $handler): RouterInterface; +} + +class SegmentRouter implements SegmentRouterInterface +{ + private array $routes = []; + + use SegmentRouterTrait; +}