Conditions | 5 |
Paths | 6 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5.3906 |
Changes | 0 |
1 | <?php |
||
19 | 2 | public function __invoke(ControllerContainer $container, $ann) |
|
20 | { |
||
21 | 2 | if(!$ann->parent){ |
|
22 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route"); |
||
23 | return; |
||
24 | } |
||
25 | 2 | $target = $ann->parent->name; |
|
26 | 2 | $route = $container->getRoute($target); |
|
27 | 2 | if(!$route){ |
|
28 | Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route"); |
||
29 | return ; |
||
30 | } |
||
31 | 2 | $params = new AnnotationParams($ann->description, 2); |
|
32 | 2 | count($params)>0 or \PhpBoot\abort("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target require at least one param, 0 given"); |
|
33 | 2 | $className = $params[0]; |
|
34 | 2 | $className = TypeHint::normalize($className, $container->getClassName()); |
|
35 | 2 | is_subclass_of($className, HookInterface::class) or \PhpBoot\abort("$className is not a HookInterface on the annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target"); |
|
|
|||
36 | 2 | $route->addHook($className); |
|
37 | } |
||
38 | } |