From 25d0c98dd7b69695d0b2a8aa24d991359b371455 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: added named routes to router --- src/Router.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') 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 */ + 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; + } } -- cgit v1.2.3