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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 12
cts 16
cp 0.75
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 5
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
}