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
commit5d30e3e60f674781950ceaa7a411449a561cd214 (patch)
tree91f043abc07a864036258e16b0c66027da74df01 /src
parentdc03419384af6def0b3adb3b976b1f5a3a46cca2 (diff)
build routes with with parameters
Diffstat (limited to 'src')
-rw-r--r--src/PathSegment.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/PathSegment.php b/src/PathSegment.php
index c2231da..d55102f 100644
--- a/src/PathSegment.php
+++ b/src/PathSegment.php
@@ -162,10 +162,16 @@ class PathSegment
return $seg;
}
- public function getPath(): string
+ /** @param array<string, string> $parameters */
+ public function getPath(array $parameters = []): string
{
$parts = array_map(
- fn ($seg) => $seg->getContent(),
+ fn ($seg) => match ($seg->getType()) {
+ PathSegmentType::Parameter => (
+ $parameters[$v = ($seg->getValue() ?? '')] ?? throw MissingParameterException::make($v)
+ ),
+ default => $seg->getContent(),
+ },
$this->getAncestorsAndSelf()
);