Total Complexity | 9 |
Total Lines | 83 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class StaticCache |
||
17 | { |
||
18 | /** @var ICache|Formatted|null */ |
||
19 | protected static $cache = null; |
||
20 | |||
21 | /** |
||
22 | * @param Formatted|ICache|null $cache |
||
23 | */ |
||
24 | 2 | public static function setCache($cache = null): void |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return Formatted|ICache|null |
||
31 | */ |
||
32 | 2 | public static function getCache() |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Init cache |
||
39 | * @param string $what |
||
40 | * @throws CacheException |
||
41 | */ |
||
42 | 2 | public static function init(string $what): void |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Is cache set? |
||
50 | * @return boolean |
||
51 | * @throws CacheException |
||
52 | */ |
||
53 | 1 | public static function exists(): bool |
|
54 | { |
||
55 | 1 | static::checkCache(); |
|
56 | 1 | return static::$cache->/** @scrutinizer ignore-call */exists(); |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * Set data into cache |
||
61 | * @param mixed $content |
||
62 | * @throws CacheException |
||
63 | * @return boolean |
||
64 | */ |
||
65 | 1 | public static function set($content): bool |
|
66 | { |
||
67 | 1 | static::checkCache(); |
|
68 | 1 | return static::$cache->/** @scrutinizer ignore-call */set($content); |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Return cache content |
||
73 | * @throws CacheException |
||
74 | * @return mixed |
||
75 | */ |
||
76 | 1 | public static function get() |
|
77 | { |
||
78 | 1 | static::checkCache(); |
|
79 | 1 | return static::$cache->/** @scrutinizer ignore-call */get(); |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * Delete data in cache |
||
84 | * @throws CacheException |
||
85 | */ |
||
86 | 1 | public static function clear(): void |
|
90 | } |
||
91 | |||
92 | /** |
||
93 | * @throws CacheException |
||
94 | */ |
||
95 | 2 | protected static function checkCache(): void |
|
102 |