Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
WithUtilsCache | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
getAll | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setAll | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
set | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
reset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Olz\Utils; |
4 | |
5 | class WithUtilsCache { |
6 | /** @var array<string, mixed> */ |
7 | private static array $utilsCache = []; |
8 | |
9 | /** @return array<string, mixed> */ |
10 | public static function getAll(): array { |
11 | return [...self::$utilsCache]; |
12 | } |
13 | |
14 | /** @param array<string, mixed> $utils */ |
15 | public static function setAll(array $utils): void { |
16 | self::$utilsCache = $utils; |
17 | } |
18 | |
19 | public static function get(string $name): mixed { |
20 | return self::$utilsCache[$name] ?? null; |
21 | } |
22 | |
23 | public static function set(string $name, mixed $util): void { |
24 | self::$utilsCache[$name] = $util; |
25 | } |
26 | |
27 | public static function reset(): void { |
28 | self::$utilsCache = []; |
29 | } |
30 | } |