Completed
Push — master ( 516660...f56fd8 )
by Cees-Jan
06:37
created

GlobalState::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Inspector;
4
5
final class GlobalState
6
{
7
    protected static $state = [];
8
9
    public static function get(): array
10
    {
11
        return self::$state;
12
    }
13
14
    public static function reset()
15
    {
16
        self::$state = [];
17
    }
18
19
    public static function set(string $key, int $value)
20
    {
21
        self::$state[$key] = $value;
22
    }
23
24 View Code Duplication
    public static function incr(string $key, int $value = 1)
0 ignored issues
show
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...
25
    {
26
        if (!isset(self::$state[$key])) {
27
            self::$state[$key] = 0;
28
        }
29
30
        self::$state[$key] += $value;
31
    }
32
33 View Code Duplication
    public static function decr(string $key, int $value = 1)
0 ignored issues
show
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...
34
    {
35
        if (!isset(self::$state[$key])) {
36
            self::$state[$key] = 0;
37
        }
38
39
        self::$state[$key] -= $value;
40
    }
41
}
42