From 5d30e3e60f674781950ceaa7a411449a561cd214 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: build routes with with parameters --- src/PathSegment.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') 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 $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() ); -- cgit v1.2.3