diff --git a/composer.json b/composer.json index b4ab9ef..fcbc3c0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "sharkk/router", "description": "A simple node-based router.", - "version": "1.2.4", + "version": "1.2.5", "type": "library", "license": "MIT", "autoload": { diff --git a/src/SegmentRouter.php b/src/Router.php similarity index 89% rename from src/SegmentRouter.php rename to src/Router.php index 69651d8..bb9400e 100644 --- a/src/SegmentRouter.php +++ b/src/Router.php @@ -2,7 +2,7 @@ namespace Sharkk\Router; -class SegmentRouter implements RouterInterface +class Router { private array $routes = []; @@ -13,7 +13,7 @@ class SegmentRouter implements RouterInterface * Example: * `$r->add('GET', '/posts/:id', function($id) { echo "Viewing post $id"; });` */ - public function add(string $method, string $route, callable $handler): RouterInterface + public function add(string $method, string $route, callable $handler): Router { // Expand the route into segments and make dynamic segments into a common placeholder $segments = array_map(function($segment) { @@ -84,7 +84,7 @@ class SegmentRouter implements RouterInterface /** * Clear all routes from the router. */ - public function clear(): RouterInterface + public function clear(): Router { $this->routes = []; return $this; @@ -101,7 +101,7 @@ class SegmentRouter implements RouterInterface /** * Register a GET route. */ - public function get(string $route, callable $handler): RouterInterface + public function get(string $route, callable $handler): Router { return $this->add('GET', $route, $handler); } @@ -109,7 +109,7 @@ class SegmentRouter implements RouterInterface /** * Register a POST route. */ - public function post(string $route, callable $handler): RouterInterface + public function post(string $route, callable $handler): Router { return $this->add('POST', $route, $handler); } @@ -117,7 +117,7 @@ class SegmentRouter implements RouterInterface /** * Register a PUT route. */ - public function put(string $route, callable $handler): RouterInterface + public function put(string $route, callable $handler): Router { return $this->add('PUT', $route, $handler); } @@ -125,7 +125,7 @@ class SegmentRouter implements RouterInterface /** * Register a PATCH route. */ - public function patch(string $route, callable $handler): RouterInterface + public function patch(string $route, callable $handler): Router { return $this->add('PATCH', $route, $handler); } @@ -133,7 +133,7 @@ class SegmentRouter implements RouterInterface /** * Register a DELETE route. */ - public function delete(string $route, callable $handler): RouterInterface + public function delete(string $route, callable $handler): Router { return $this->add('DELETE', $route, $handler); } @@ -141,7 +141,7 @@ class SegmentRouter implements RouterInterface /** * Register a HEAD route. */ - public function head(string $route, callable $handler): RouterInterface + public function head(string $route, callable $handler): Router { return $this->add('HEAD', $route, $handler); } diff --git a/src/RouterInterface.php b/src/RouterInterface.php deleted file mode 100644 index 5488e6f..0000000 --- a/src/RouterInterface.php +++ /dev/null @@ -1,9 +0,0 @@ -