summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
committerSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
commit25d0c98dd7b69695d0b2a8aa24d991359b371455 (patch)
treed272b81f296f057d0d948f2e37022ebe712b0ba2 /src
parent7f3ad6625e00e39cad47cbfca97e6b872712d10a (diff)
added named routes to router
Diffstat (limited to 'src')
-rw-r--r--src/Router.php13
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;
+ }
}