1 | <?php declare(strict_types=1); |
||
15 | class FileCache |
||
16 | { |
||
17 | |||
18 | private $cachePath; |
||
19 | |||
20 | /** |
||
21 | * FileCache constructor. |
||
22 | * @param null|string $cachePath |
||
23 | */ |
||
24 | 2 | public function __construct(?string $cachePath = null) |
|
29 | |||
30 | /** |
||
31 | * Clear cache directory |
||
32 | * |
||
33 | * @return bool |
||
34 | */ |
||
35 | 1 | public function clear(): bool |
|
47 | |||
48 | /** |
||
49 | * @param array $keys |
||
50 | * @param mixed $default |
||
51 | * @return array |
||
52 | * @throws LogicException |
||
53 | * @throws RuntimeException |
||
54 | * @throws InvalidArgumentException |
||
55 | */ |
||
56 | 1 | public function getMultiple(array $keys, $default = null): array |
|
65 | |||
66 | /** |
||
67 | * @param string $key |
||
68 | * @param null $default |
||
69 | * @return mixed |
||
70 | * @throws LogicException |
||
71 | * @throws RuntimeException |
||
72 | * @throws InvalidArgumentException |
||
73 | */ |
||
74 | 2 | public function get(string $key, $default = null) |
|
82 | |||
83 | /** |
||
84 | * @param string $key |
||
85 | * @return string |
||
86 | * @throws InvalidArgumentException |
||
87 | */ |
||
88 | 6 | private function getFilename(string $key): string |
|
98 | |||
99 | /** |
||
100 | * @param $key |
||
101 | * @return bool |
||
102 | * @throws InvalidArgumentException |
||
103 | */ |
||
104 | 6 | private function validateKey(string $key): bool |
|
112 | |||
113 | /** |
||
114 | * Isset and life item |
||
115 | * |
||
116 | * @param string $key |
||
117 | * @return bool |
||
118 | * @throws InvalidArgumentException |
||
119 | */ |
||
120 | 3 | public function has(string $key): bool |
|
133 | |||
134 | /** |
||
135 | * @param $ttl int |
||
136 | * @return bool |
||
137 | */ |
||
138 | 3 | private function isLife($ttl): bool |
|
142 | |||
143 | /** |
||
144 | * @param string $key |
||
145 | * @return bool |
||
146 | * @throws InvalidArgumentException |
||
147 | */ |
||
148 | 2 | public function delete($key): bool |
|
152 | |||
153 | /** |
||
154 | * @param array $keys |
||
155 | * @param int $ttl |
||
156 | * @throws InvalidArgumentException |
||
157 | * @throws LogicException |
||
158 | * @throws RuntimeException |
||
159 | * @return bool |
||
160 | */ |
||
161 | 1 | public function setMultiple(array $keys, $ttl = null): bool |
|
170 | |||
171 | /** |
||
172 | * @param string $key |
||
173 | * @param mixed $value |
||
174 | * @param null|int|\DateInterval $ttl |
||
175 | * @throws InvalidArgumentException |
||
176 | * @throws LogicException |
||
177 | * @throws RuntimeException |
||
178 | * @return bool |
||
179 | */ |
||
180 | 3 | public function set(string $key, $value, $ttl = null): bool |
|
203 | |||
204 | /** |
||
205 | * @param array $keys |
||
206 | * @return bool |
||
207 | * @throws InvalidArgumentException |
||
208 | */ |
||
209 | 1 | public function deleteMultiple(array $keys): bool |
|
218 | } |
||
219 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.