Total Complexity | 8 |
Total Lines | 73 |
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 | 2 | } |
|
28 | |||
29 | /** |
||
30 | * @throws CacheException |
||
31 | * @return Formatted|ICache |
||
32 | */ |
||
33 | 2 | public static function getCache() |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Init cache |
||
43 | * @param string[] $what |
||
44 | * @throws CacheException |
||
45 | */ |
||
46 | 1 | public static function init(array $what): void |
|
49 | 1 | } |
|
50 | |||
51 | /** |
||
52 | * Is cache set? |
||
53 | * @throws CacheException |
||
54 | * @return boolean |
||
55 | */ |
||
56 | 1 | public static function exists(): bool |
|
57 | { |
||
58 | 1 | return static::getCache()->exists(); |
|
59 | } |
||
60 | |||
61 | /** |
||
62 | * Set data into cache |
||
63 | * @param mixed $content |
||
64 | * @throws CacheException |
||
65 | * @return boolean |
||
66 | */ |
||
67 | 1 | public static function set($content): bool |
|
68 | { |
||
69 | 1 | return static::getCache()->set($content); |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Return cache content |
||
74 | * @throws CacheException |
||
75 | * @return mixed |
||
76 | */ |
||
77 | 1 | public static function get() |
|
78 | { |
||
79 | 1 | return static::getCache()->get(); |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * Delete data in cache |
||
84 | * @throws CacheException |
||
85 | */ |
||
86 | 1 | public static function clear(): void |
|
89 | 1 | } |
|
90 | } |
||
91 |