Lines
0.00%
0 / 7
Methods
0.00%
0 / 3
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 2 | ||
| middleware | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 2 | ||
| registerRoute | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 2 | ||
| buildPath | n/a | 0 / 0 | n/a | 0 / 0 | 0 | ||
| 9 | abstract class RouteGroup | |
| 10 | { | |
| 11 | protected string $name; | |
| 12 | protected array $middleware = []; | |
| 13 | protected Router $router; | |
| 14 | ||
| 15 | ||
| 16 | public function __construct(string $name, Router $router) | |
| 17 | { | |
| 18 | $this->name = $name; | |
| 19 | $this->router = $router; | |
| 20 | } | |
| 21 | ||
| 22 | public function middleware(array $middleware): static | |
| 23 | { | |
| 24 | $this->middleware = $middleware; | |
| 25 | return $this; | |
| 26 | } | |
| 27 | ||
| 28 | protected function registerRoute(string $path, string $type, array $handler): static | |
| 29 | { | |
| 30 | $fullPath = $this->buildPath($path); | |
| 31 | $this->router->registerRoute($fullPath, $type, $handler[1], $handler[0], $this->middleware); | |
| 32 | return $this; | |
| 33 | } | |
| 34 | ||
| 35 | abstract protected function buildPath(string $path): string; | |
| 36 | ||
| 37 | } |