Tweaks and optimizations #2

Open
valithor wants to merge 6 commits from valithor/dev:master into master
Showing only changes of commit 1c58ff3a59 - Show all commits

View File

@ -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;
}