1 | <?php declare(strict_types = 1); |
||
13 | class RoutePathProcessor implements RoutePathProcessorContract |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Patterns to apply to route path: [pattern => replacement]. |
||
18 | * |
||
19 | * @var string[] |
||
20 | */ |
||
21 | private $patterns = []; |
||
22 | |||
23 | /** |
||
24 | * @inheritDoc |
||
25 | */ |
||
26 | 2 | public function addPattern(string $placeholder, string $regex): RoutePathProcessorContract |
|
32 | |||
33 | /** |
||
34 | * @inheritDoc |
||
35 | */ |
||
36 | 2 | public function process(RouteContract $route): RouteContract |
|
44 | |||
45 | /** |
||
46 | * Replaces {?placeholder} with [{placeholder}] FastRoute syntax. |
||
47 | * Respects following segments by adding ] to the end. |
||
48 | * |
||
49 | * @param string $path |
||
50 | * @return string |
||
51 | */ |
||
52 | 2 | private function processOptionalPlaceholders(string $path): string |
|
56 | |||
57 | |||
58 | } |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.