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