diff options
Diffstat (limited to 'src/Router.php')
| -rw-r--r-- | src/Router.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Router.php b/src/Router.php index 5757b35..9aa3b55 100644 --- a/src/Router.php +++ b/src/Router.php @@ -15,6 +15,9 @@ class Router private PathSegment $root; private Strategy $strategy; + /** @var array<string, Route> */ + private array $namedRoutes = []; + public function __construct() { $this->root = new PathSegment(type: PathSegmentType::Root); @@ -161,4 +164,14 @@ class Router { return $this->route(HttpMethod::Any, $path, $handler); } + + public function addNamedRoute(string $name, Route $route): void + { + $this->namedRoutes[$name] = $route; + } + + public function getNamedRoute(string $name): ?Route + { + return $this->namedRoutes[$name] ?? null; + } } |
