1 | <?php |
||
13 | final class BrowscapCache implements BrowscapCacheInterface |
||
14 | { |
||
15 | /** |
||
16 | * Path to the cache directory |
||
17 | * |
||
18 | * @var \Psr\SimpleCache\CacheInterface |
||
19 | */ |
||
20 | private $cache = null; |
||
21 | |||
22 | /** |
||
23 | * @var \Psr\Log\LoggerInterface|null |
||
24 | */ |
||
25 | private $logger; |
||
26 | |||
27 | /** |
||
28 | * Detected browscap version (read from INI file) |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | private $version = null; |
||
33 | |||
34 | /** |
||
35 | * Release date of the Browscap data (read from INI file) |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $releaseDate; |
||
40 | |||
41 | /** |
||
42 | * Type of the Browscap data (read from INI file) |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $type; |
||
47 | |||
48 | /** |
||
49 | * Constructor class, checks for the existence of (and loads) the cache and |
||
50 | * if needed updated the definitions |
||
51 | * |
||
52 | * @param \Psr\SimpleCache\CacheInterface $adapter |
||
53 | * @param LoggerInterface $logger |
||
54 | */ |
||
55 | 4 | public function __construct(CacheInterface $adapter, LoggerInterface $logger) |
|
60 | |||
61 | /** |
||
62 | * Gets the version of the Browscap data |
||
63 | * |
||
64 | * @return int |
||
65 | */ |
||
66 | 2 | public function getVersion() : ?int |
|
85 | |||
86 | /** |
||
87 | * Gets the release date of the Browscap data |
||
88 | * |
||
89 | * @return string|null |
||
90 | */ |
||
91 | 1 | public function getReleaseDate() : ?string |
|
110 | |||
111 | /** |
||
112 | * Gets the type of the Browscap data |
||
113 | */ |
||
114 | 1 | public function getType() : ?string |
|
133 | |||
134 | /** |
||
135 | * Get an item. |
||
136 | * |
||
137 | * @param string $cacheId |
||
138 | * @param bool $withVersion |
||
139 | * @param bool &$success |
||
140 | * |
||
141 | * @return mixed Data on success, null on failure |
||
142 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
143 | */ |
||
144 | 3 | public function getItem(string $cacheId, bool $withVersion = true, ?bool &$success = null) |
|
168 | |||
169 | /** |
||
170 | * save the content into an php file |
||
171 | * |
||
172 | * @param string $cacheId The cache id |
||
173 | * @param mixed $content The content to store |
||
174 | * @param bool $withVersion |
||
175 | * |
||
176 | * @return bool whether the file was correctly written to the disk |
||
177 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
178 | */ |
||
179 | 3 | public function setItem(string $cacheId, $content, bool $withVersion = true) : bool |
|
193 | |||
194 | /** |
||
195 | * Test if an item exists. |
||
196 | * |
||
197 | * @param string $cacheId |
||
198 | * @param bool $withVersion |
||
199 | * |
||
200 | * @return bool |
||
201 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
202 | */ |
||
203 | public function hasItem(string $cacheId, bool $withVersion = true) : bool |
||
212 | |||
213 | /** |
||
214 | * Remove an item. |
||
215 | * |
||
216 | * @param string $cacheId |
||
217 | * @param bool $withVersion |
||
218 | * |
||
219 | * @return bool |
||
220 | * @throws \Psr\SimpleCache\InvalidArgumentException |
||
221 | */ |
||
222 | public function removeItem(string $cacheId, bool $withVersion = true) : bool |
||
230 | |||
231 | /** |
||
232 | * Flush the whole storage |
||
233 | * |
||
234 | * @return bool |
||
235 | */ |
||
236 | public function flush() : bool |
||
240 | } |
||
241 |