| Total Complexity | 10 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 47.62% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Group implements RouteCollectorInterface |
||
| 10 | { |
||
| 11 | protected array $items = []; |
||
| 12 | protected ?string $prefix; |
||
| 13 | protected array $middlewares = []; |
||
| 14 | |||
| 15 | 1 | public function __construct(?string $prefix = null, ?callable $callback = null) |
|
| 16 | { |
||
| 17 | 1 | $this->prefix = $prefix; |
|
| 18 | |||
| 19 | 1 | if ($callback !== null) { |
|
| 20 | $callback($this); |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | final public function addRoute(Route $route): void |
||
| 25 | { |
||
| 26 | $this->items[] = $route; |
||
| 27 | } |
||
| 28 | |||
| 29 | final public function addGroup(string $prefix, callable $callback): void |
||
| 30 | { |
||
| 31 | $this->items[] = new Group($prefix, $callback); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param callable|MiddlewareInterface $middleware |
||
| 36 | * @return $this |
||
| 37 | */ |
||
| 38 | 1 | final public function addMiddleware($middleware): self |
|
| 51 | } |
||
| 52 | |||
| 53 | final public function getItems(): array |
||
| 54 | { |
||
| 55 | return $this->items; |
||
| 56 | } |
||
| 57 | |||
| 58 | final public function getPrefix(): ?string |
||
| 59 | { |
||
| 60 | return $this->prefix; |
||
| 61 | } |
||
| 62 | |||
| 63 | 1 | final public function getMiddlewares(): array |
|
| 66 | } |
||
| 67 | } |
||
| 68 |