Total Complexity | 12 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | class DebuggerStore implements StorageInterface |
||
23 | { |
||
24 | private static $store = []; |
||
25 | |||
26 | /** |
||
27 | * @param array $keys |
||
28 | * @return void |
||
29 | */ |
||
30 | public function init(array $keys) |
||
31 | { |
||
32 | foreach ($keys as $key) { |
||
33 | if (!isset(self::$store[$key])) { |
||
34 | self::$store[$key] = []; |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return array[] |
||
41 | */ |
||
42 | public function all(): array |
||
43 | { |
||
44 | return self::$store; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $key |
||
49 | * @return bool |
||
50 | */ |
||
51 | public function has(string $key): bool |
||
52 | { |
||
53 | return isset(self::$store[$key]); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param string $key |
||
58 | * @return array |
||
59 | */ |
||
60 | public function get(string $key): array |
||
61 | { |
||
62 | return self::$store[$key] ?? []; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param string $key |
||
67 | * @param mixed $value |
||
68 | * @return void |
||
69 | */ |
||
70 | public function set(string $key, $value) |
||
71 | { |
||
72 | if (is_array($value)) { |
||
73 | foreach ($value as $level => $data) { |
||
74 | self::$store[$key][] = [$level => $data]; |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @param string $key |
||
81 | * @return void |
||
82 | */ |
||
83 | public function delete(string $key) |
||
84 | { |
||
85 | if ($this->has($key)) { |
||
86 | self::$store[$key] = []; |
||
87 | } |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return void |
||
92 | */ |
||
93 | public function flush() |
||
96 | } |
||
97 | } |
||
98 |