| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4.0582 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 3 | public function __invoke(ControllerContainer $container, $ann) |
|
| 21 | { |
||
| 22 | 3 | if(!$ann->parent){ |
|
| 23 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route"); |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | 3 | $target = $ann->parent->name; |
|
| 27 | 3 | $route = $container->getRoute($target); |
|
| 28 | 3 | if(!$route){ |
|
| 29 | //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route"); |
||
| 30 | return ; |
||
| 31 | } |
||
| 32 | 3 | $params = new AnnotationParams($ann->description, 2); |
|
| 33 | 3 | count($params)>0 or \PhpBoot\abort(new AnnotationSyntaxException("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target require at least one param, {$params->count()} given")); |
|
| 34 | |||
| 35 | 3 | $type = TypeHint::normalize($params[0], $container->getClassName()); // TODO 缺少类型时忽略错误 |
|
| 36 | 3 | $doc = $params->getRawParam(1, ''); |
|
| 37 | |||
| 38 | 3 | $route->getExceptionHandler()->addExceptions($type, $doc); |
|
| 39 | } |
||
| 40 | } |