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.
Passed
Push — master ( 5205fe...5906b8 )
by Baptiste
03:02
created

MapBench::benchEquals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
declare(strict_types = 1);
3
4
use Innmind\Immutable\Map;
5
6
final class MapBench
7
{
8
    private $data;
9
    private $map;
10
11
    public function __construct()
12
    {
13
        $this->data = unserialize(file_get_contents(__DIR__.'/fixtures.data'));
14
        $this->map = Map::of(
15
            'int',
16
            'int',
17
            array_keys($this->data),
18
            array_values($this->data)
19
        );
20
    }
21
22
    public function benchNamedConstructor()
23
    {
24
        Map::of(
25
            'int',
26
            'int',
27
            array_keys($this->data),
28
            array_values($this->data)
29
        );
30
    }
31
32
    public function benchGet()
33
    {
34
        $this->map->get(500);
35
    }
36
37
    public function benchContains()
38
    {
39
        $this->map->contains(500);
40
    }
41
42
    public function benchEquals()
43
    {
44
        $this->map->equals($this->map);
45
    }
46
47
    public function benchFilter()
48
    {
49
        $this->map->filter(static function(int $k, int $v): bool {
50
            return $v % 2 === 0;
51
        });
52
    }
53
54
    public function benchForeach()
55
    {
56
        $this->map->foreach(static function(int $k, int $v): void {
0 ignored issues
show
Unused Code introduced by
The parameter $v is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
        $this->map->foreach(static function(int $k, /** @scrutinizer ignore-unused */ int $v): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $k is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

56
        $this->map->foreach(static function(/** @scrutinizer ignore-unused */ int $k, int $v): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
            // pass
58
        });
59
    }
60
61
    public function benchGroupBy()
62
    {
63
        $this->map->groupBy(static function(int $k, int $v): int {
0 ignored issues
show
Unused Code introduced by
The parameter $k is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
        $this->map->groupBy(static function(/** @scrutinizer ignore-unused */ int $k, int $v): int {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $v is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
        $this->map->groupBy(static function(int $k, /** @scrutinizer ignore-unused */ int $v): int {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
            return $i % 2;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $i seems to be never defined.
Loading history...
65
        });
66
    }
67
68
    public function benchKeys()
69
    {
70
        $this->map->keys();
71
    }
72
73
    public function benchValues()
74
    {
75
        $this->map->values();
76
    }
77
78
    public function benchMap()
79
    {
80
        $this->map->map(static function(int $i): int {
81
            return $i ** 2;
82
        });
83
    }
84
85
    public function benchRemove()
86
    {
87
        $this->map->remove(500);
88
    }
89
90
    public function benchMerge()
91
    {
92
        $this->map->merge($this->map);
93
    }
94
95
    public function benchPartition()
96
    {
97
        $this->map->partition(static function(int $k, int $v): bool {
98
            return $v % 2 === 0;
99
        });
100
    }
101
102
    public function benchReduce()
103
    {
104
        $this->map->reduce(
105
            0,
106
            static function(int $sump, int $k, int $v): int {
107
                return $sum + $k + $v;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $sum does not exist. Did you maybe mean $sump?
Loading history...
108
            }
109
        );
110
    }
111
}
112