| Total Complexity | 7 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | final class RouteCollector implements RouteCollectorInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Group[]|Route[] |
||
| 13 | */ |
||
| 14 | private array $items = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var RoutesProviderInterface[] |
||
| 18 | */ |
||
| 19 | private array $providers = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var array[]|callable[]|string[] |
||
| 23 | */ |
||
| 24 | private array $middlewareDefinitions = []; |
||
| 25 | |||
| 26 | 30 | public function addRoute(Route|Group ...$routes): RouteCollectorInterface |
|
| 27 | { |
||
| 28 | 30 | array_push( |
|
| 29 | 30 | $this->items, |
|
| 30 | 30 | ...array_values($routes) |
|
| 31 | 30 | ); |
|
| 32 | 30 | return $this; |
|
| 33 | } |
||
| 34 | |||
| 35 | 1 | public function addProvider(RoutesProviderInterface ...$provider): RouteCollectorInterface |
|
| 42 | } |
||
| 43 | |||
| 44 | 6 | public function middleware(array|callable|string ...$middlewareDefinition): RouteCollectorInterface |
|
| 45 | { |
||
| 46 | 6 | array_push( |
|
| 47 | 6 | $this->middlewareDefinitions, |
|
| 48 | 6 | ...array_values($middlewareDefinition) |
|
| 49 | 6 | ); |
|
| 50 | 6 | return $this; |
|
| 51 | } |
||
| 52 | |||
| 53 | 4 | public function prependMiddleware(array|callable|string ...$middlewareDefinition): RouteCollectorInterface |
|
| 54 | { |
||
| 55 | 4 | array_unshift( |
|
| 56 | 4 | $this->middlewareDefinitions, |
|
| 57 | 4 | ...array_values($middlewareDefinition) |
|
| 58 | 4 | ); |
|
| 59 | 4 | return $this; |
|
| 60 | } |
||
| 61 | |||
| 62 | 30 | public function getItems(): array |
|
| 71 | } |
||
| 72 | |||
| 73 | 28 | public function getMiddlewareDefinitions(): array |
|
| 76 | } |
||
| 77 | } |
||
| 78 |