| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 1 | public function register(): void |
|
| 20 | { |
||
| 21 | //TODO: caching? |
||
| 22 | 1 | $classes = get_declared_classes(); |
|
| 23 | 1 | foreach ($classes as $class) { |
|
| 24 | 1 | $reflectionClass = new \ReflectionClass($class); |
|
| 25 | 1 | if (!$reflectionClass->isUserDefined()) { |
|
| 26 | 1 | continue; |
|
| 27 | } |
||
| 28 | 1 | $routes = $this->lookupRoutes($reflectionClass); |
|
| 29 | 1 | $groupAttributes = $reflectionClass->getAttributes(Group::class, \ReflectionAttribute::IS_INSTANCEOF); |
|
| 30 | |||
| 31 | 1 | if (!empty($groupAttributes)) { |
|
| 32 | 1 | [$groupAttribute] = $groupAttributes; |
|
| 33 | /** @var Group $group */ |
||
| 34 | 1 | $group = $groupAttribute->newInstance(); |
|
| 35 | 1 | $this->routeCollector->addRoute($group->routes(...iterator_to_array($routes))); |
|
| 36 | } else { |
||
| 37 | 1 | $this->routeCollector->addRoute(...iterator_to_array($routes)); |
|
| 38 | } |
||
| 62 |