Completed
Push — master ( 61c19f...f7d981 )
by Peter
03:44
created

CompareInitEnumBench   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A benchReflectionEnum() 0 4 1
A benchReflectionEnumNoMagic() 0 4 1
A benchExplicitEnum() 0 4 1
A benchMyCLabsEnum() 0 4 1
A benchMabeEnum() 0 4 1
A benchMabeNoMagicEnum() 0 4 1
A benchHappyTypesEnum() 0 4 1
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2017, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Enum\Bench\Compare\Operation;
12
13
use GpsLab\Component\Enum\Bench\Compare\CompareEnumBench;
14
use GpsLab\Component\Enum\Tests\Fixture\Enum\AbcExp;
15
use GpsLab\Component\Enum\Tests\Fixture\Enum\AbcRef;
16
use GpsLab\Component\Enum\Tests\Fixture\Enum\DefRef;
17
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcHappyTypes;
18
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcMarcMabe;
19
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\AbcMyClabs;
20
use GpsLab\Component\Enum\Tests\Fixture\Enum\Rival\DefMarcMabe;
21
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
22
use PhpBench\Benchmark\Metadata\Annotations\Revs;
23
24
/**
25
 * @Revs(2500)
26
 * @Iterations(25)
27
 */
28
class CompareInitEnumBench implements CompareEnumBench
29
{
30
    public function benchReflectionEnum()
31
    {
32
        $a = AbcRef::A();
0 ignored issues
show
Unused Code introduced by
$a 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...
33
    }
34
35
    public function benchReflectionEnumNoMagic()
36
    {
37
        $d = DefRef::byValue(DefRef::D);
0 ignored issues
show
Unused Code introduced by
$d 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...
38
    }
39
40
    public function benchExplicitEnum()
41
    {
42
        $a = AbcExp::byValue(AbcExp::A);
0 ignored issues
show
Unused Code introduced by
$a 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...
43
    }
44
45
    public function benchMyCLabsEnum()
46
    {
47
        $a = AbcMyClabs::A();
0 ignored issues
show
Unused Code introduced by
$a 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...
48
    }
49
50
    public function benchMabeEnum()
51
    {
52
        $a = AbcMarcMabe::A();
0 ignored issues
show
Unused Code introduced by
$a 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...
53
    }
54
55
    public function benchMabeNoMagicEnum()
56
    {
57
        $d = DefMarcMabe::byValue(DefMarcMabe::D);
0 ignored issues
show
Unused Code introduced by
$d 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...
58
    }
59
60
    public function benchHappyTypesEnum()
61
    {
62
        $a = AbcHappyTypes::A();
0 ignored issues
show
Unused Code introduced by
$a 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...
63
    }
64
}
65