| Total Complexity | 5 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class RouteCollector implements RouteCollectorInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var Group[]|RoutableInterface[]|Route[] |
||
| 11 | */ |
||
| 12 | private array $items = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var array[]|callable[]|string[] |
||
| 16 | */ |
||
| 17 | private array $middlewares = []; |
||
| 18 | |||
| 19 | 33 | public function addRoute(Route|Group|RoutableInterface ...$routes): RouteCollectorInterface |
|
| 26 | } |
||
| 27 | |||
| 28 | 6 | public function middleware(array|callable|string ...$definition): RouteCollectorInterface |
|
| 29 | { |
||
| 30 | 6 | array_push( |
|
| 31 | 6 | $this->middlewares, |
|
| 32 | 6 | ...array_values($definition) |
|
| 33 | 6 | ); |
|
| 34 | 6 | return $this; |
|
| 35 | } |
||
| 36 | |||
| 37 | 4 | public function prependMiddleware(array|callable|string ...$definition): RouteCollectorInterface |
|
| 38 | { |
||
| 39 | 4 | array_unshift( |
|
| 40 | 4 | $this->middlewares, |
|
| 41 | 4 | ...array_values($definition) |
|
| 42 | 4 | ); |
|
| 43 | 4 | return $this; |
|
| 44 | } |
||
| 45 | |||
| 46 | 31 | public function getItems(): array |
|
| 49 | } |
||
| 50 | |||
| 51 | 30 | public function getMiddlewares(): array |
|
| 56 |