diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
| commit | 5d30e3e60f674781950ceaa7a411449a561cd214 (patch) | |
| tree | 91f043abc07a864036258e16b0c66027da74df01 /src | |
| parent | dc03419384af6def0b3adb3b976b1f5a3a46cca2 (diff) | |
build routes with with parameters
Diffstat (limited to 'src')
| -rw-r--r-- | src/PathSegment.php | 10 |
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() ); |
