Trait, Interface, Class

This commit is contained in:
Valithor Obsidion 2024-12-25 10:59:20 -05:00
parent 1eed623c18
commit 1c58ff3a59

View File

@ -2,10 +2,8 @@
namespace Sharkk\Router; 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 * 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) * using a colon prefix. (:id, :slug, etc)
@ -172,3 +170,23 @@ class SegmentRouter implements RouterInterface
return $this->add('HEAD', $route, $handler); 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;
}