Total Complexity | 8 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 75% |
Changes | 0 |
1 | <?php |
||
9 | final class InMemoryCache implements CacheInterface |
||
10 | { |
||
11 | /** @var array<string, array<string,string>> */ |
||
12 | 53 | private static array $cache = []; |
|
13 | |||
14 | public function __construct( |
||
15 | 53 | private readonly string $key, |
|
16 | ) { |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | 2 | * @internal |
|
21 | * |
||
22 | 2 | * @return array<string, string> |
|
23 | */ |
||
24 | public static function getAllFromKey(string $key): array |
||
25 | { |
||
26 | return self::$cache[$key] ?? []; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @internal |
||
31 | * |
||
32 | * @return array<string, array<string,string>> |
||
33 | */ |
||
34 | public static function all(): array |
||
35 | { |
||
36 | 58 | return self::$cache; |
|
37 | } |
||
38 | 58 | ||
39 | /** |
||
40 | * @internal |
||
41 | */ |
||
42 | public static function resetCache(): void |
||
43 | { |
||
44 | self::$cache = []; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return array<string, string> |
||
49 | 74 | */ |
|
50 | #[Override] |
||
51 | 74 | public function getAll(): array |
|
52 | { |
||
53 | return self::$cache[$this->key] ?? []; |
||
54 | 29 | } |
|
55 | |||
56 | 29 | #[Override] |
|
60 | } |
||
61 | 58 | ||
62 | #[Override] |
||
63 | public function get(string $cacheKey): string |
||
66 | } |
||
67 | |||
68 | #[Override] |
||
72 | } |
||
73 | } |
||
74 |