| 1 | <?php declare(strict_types = 1); |
||
| 13 | final 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 | } |