These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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
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 |
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.