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.

ReturnAnnotationHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 90.48%

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 19
cts 21
cp 0.9048
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 29 6
1
<?php
2
3
namespace PhpBoot\Controller\Annotations;
4
5
6
use PhpBoot\Annotation\AnnotationBlock;
7
use PhpBoot\Annotation\AnnotationTag;
8
use PhpBoot\Controller\ControllerContainer;
9
use PhpBoot\Entity\ContainerFactory;
10
use PhpBoot\Entity\EntityContainerBuilder;
11
use PhpBoot\Utils\AnnotationParams;
12
use PhpBoot\Utils\Logger;
13
use PhpBoot\Utils\TypeHint;
14
15
class ReturnAnnotationHandler
16
{
17
    /**
18
     * @param ControllerContainer $container
19
     * @param AnnotationBlock|AnnotationTag $ann
20
     * @param EntityContainerBuilder $entityBuilder
21
     */
22 4
    public function __invoke(ControllerContainer $container, $ann, EntityContainerBuilder $entityBuilder)
23
    {
24 4
        if(!$ann->parent){
25
            //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent route");
26
            return;
27
        }
28 4
        $target = $ann->parent->name;
29 4
        $route = $container->getRoute($target);
30 4
        if(!$route){
31
            //Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent route");
32
            return ;
33
        }
34
35 4
        $params = new AnnotationParams($ann->description, 2);
36 4
        $type = $doc = null;
0 ignored issues
show
Unused Code introduced by
$doc is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
37 4
        if(count($params)>0){
38 4
            $type = TypeHint::normalize($params[0], $container->getClassName());
39 4
        }
40 4
        $doc = $params->getRawParam(1, '');
41
42
        list($_, $meta) = $route
0 ignored issues
show
Unused Code introduced by
The assignment to $_ is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
43 4
            ->getResponseHandler()
44 4
            ->getMappingBySource('return');
45 4
        if($meta){
46 4
            $meta->description = $doc;
47 4
            $meta->type = $type;
48 4
            $meta->container = $type == 'void'?null:ContainerFactory::create($entityBuilder, $type);
49 4
        }
50
    }
51
}