| Conditions | 5 |
| Paths | 5 |
| Total Lines | 32 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function createRoutesFrom(string $classname): RouteCollectionInterface |
||
| 26 | { |
||
| 27 | if (!class_exists($classname)) { |
||
| 28 | return new RouteCollection([]); |
||
| 29 | } |
||
| 30 | |||
| 31 | $classReflector = new \ReflectionClass($classname); |
||
| 32 | |||
| 33 | if (!$classReflector->isInstantiable()) { |
||
| 34 | return new RouteCollection([]); |
||
| 35 | } |
||
| 36 | |||
| 37 | $classAnnotations = $this->reader->getClassAnnotations($classReflector); |
||
| 38 | |||
| 39 | $routes = []; |
||
| 40 | |||
| 41 | foreach ($classReflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodReflector) { |
||
| 42 | if ($methodReflector->isConstructor()) { |
||
| 43 | continue; |
||
| 44 | } |
||
| 45 | |||
| 46 | $routes[] = new RouteObject( |
||
| 47 | $classReflector->getName(), |
||
| 48 | $methodReflector->getName(), |
||
| 49 | array_merge( |
||
| 50 | $classAnnotations, |
||
| 51 | $this->reader->getMethodAnnotations($methodReflector) |
||
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | return new RouteCollection($routes); |
||
| 57 | } |
||
| 59 |