GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HookAnnotationHandler::__invoke()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5.3906

Importance

Changes 0
Metric Value
cc 5
nc 6
nop 2
dl 0
loc 19
ccs 12
cts 16
cp 0.75
crap 5.3906
rs 9.3222
c 0
b 0
f 0
1
<?php
2
3
namespace PhpBoot\Controller\Annotations;
4
5
use PhpBoot\Annotation\AnnotationBlock;
6
use PhpBoot\Annotation\AnnotationTag;
7
use PhpBoot\Controller\ControllerContainer;
8
use PhpBoot\Controller\HookInterface;
9
use PhpBoot\Utils\AnnotationParams;
10
use PhpBoot\Utils\Logger;
11
use PhpBoot\Utils\TypeHint;
12
13
class HookAnnotationHandler
14
{
15
    /**
16
     * @param ControllerContainer $container
17
     * @param AnnotationBlock|AnnotationTag $ann
18
     */
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");
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \PhpBoot\Controller\HookInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
36 2
        $route->addHook($className);
37
    }
38
}