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.
Completed
Push — master ( 579460...fd060d )
by Baptiste
04:45 queued 10s
created

MapObjectBench   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 37
c 1
b 0
f 1
dl 0
loc 106
ccs 0
cts 78
cp 0
rs 10
wmc 15
1
<?php
2
declare(strict_types = 1);
3
4
use Innmind\Immutable\Map;
5
6
final class MapObjectBench
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
            'stdClass',
16
            'int',
17
            array_map(function() {
18
                return new \stdClass;
19
            }, array_keys($this->data)),
20
            array_values($this->data)
21
        );
22
    }
23
24
    public function benchNamedConstructor()
25
    {
26
        Map::of(
27
            'stdClass',
28
            'int',
29
            array_map(function() {
30
                return new \stdClass;
31
            }, array_keys($this->data)),
32
            array_values($this->data)
33
        );
34
    }
35
36
    public function benchGet()
37
    {
38
        $this->map->get($this->map->key());
39
    }
40
41
    public function benchContains()
42
    {
43
        $this->map->contains(new \stdClass);
44
    }
45
46
    public function benchEquals()
47
    {
48
        $this->map->equals($this->map);
49
    }
50
51
    public function benchFilter()
52
    {
53
        $this->map->filter(static function(\stdClass $k, int $v): bool {
54
            return $v % 2 === 0;
55
        });
56
    }
57
58
    public function benchForeach()
59
    {
60
        $this->map->foreach(static function(\stdClass $k, int $v): void {
61
            // pass
62
        });
63
    }
64
65
    public function benchGroupBy()
66
    {
67
        $this->map->groupBy(static function(\stdClass $k, int $v): int {
68
            return $v % 2;
69
        });
70
    }
71
72
    public function benchKeys()
73
    {
74
        $this->map->keys();
75
    }
76
77
    public function benchValues()
78
    {
79
        $this->map->values();
80
    }
81
82
    public function benchMap()
83
    {
84
        $this->map->map(static function(\stdClass $k, int $i): int {
85
            return $i ** 2;
86
        });
87
    }
88
89
    public function benchRemove()
90
    {
91
        $this->map->remove($this->map->key());
92
    }
93
94
    public function benchMerge()
95
    {
96
        $this->map->merge($this->map);
97
    }
98
99
    public function benchPartition()
100
    {
101
        $this->map->partition(static function(\stdClass $k, int $v): bool {
102
            return $v % 2 === 0;
103
        });
104
    }
105
106
    public function benchReduce()
107
    {
108
        $this->map->reduce(
109
            0,
110
            static function(int $sum, \stdClass $k, int $v): int {
111
                return $sum + $v;
112
            }
113
        );
114
    }
115
}
116