Completed
Pull Request — master (#448)
by
unknown
08:31
created

Logical   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 8 7
1
<?php
2
class SwitchCase // ccn2: 4
3
{
4
    function __invoke()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
5
    {
6
        switch ('abc') {
7
            case 'abc':
8
            case 'def':
9
            case 'hij':
10
                break;
11
            default:
12
        }
13
    }
14
}
15
16
class IfElseif // ccn2: 7
17
{
18 View Code Duplication
    function __invoke()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        if (true) {
21
            if (true) {
22
            } elseif (true) {
23
            } else {
24
            }
25
        } elseif (true) {
26
            if (false) {
27
            }
28
        }
29
30
        if (true) {
31
        }
32
    }
33
}
34
35
class Loops // ccn2: 5
36
{
37
    function __invoke()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
    {
39
        while (true) {
40
            do {
41
            } while (false);
42
        }
43
        foreach ([] as $each) {
44
            for ($i = 0; $i < 0; ++$i) {
45
            }
46
        }
47
    }
48
}
49
50
class CatchIt // ccn2: 3
51
{
52
    function __invoke()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
53
    {
54
        try {
55
        } catch (Exception $e) {
0 ignored issues
show
Unused Code introduced by
catch (\Exception $e) { } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
56
        } catch (Throwable $e) {
57
        } finally {
58
        }
59
    }
60
}
61
62
class Logical // ccn2: 11
63
{
64
    function __invoke()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
65
    {
66
        $a = (true || false) && (false && true) || (true xor false);
67
        $b = $a ? 1 : 2;
68
        $c = $b ?: 0;
69
        $d = $b ?? $c;
70
        $e = $b <=> $d;
0 ignored issues
show
Unused Code introduced by
$e 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...
71
    }
72
}
73