1 | <?php |
||
12 | final class BrowscapCache implements BrowscapCacheInterface |
||
13 | { |
||
14 | /** |
||
15 | * Path to the cache directory |
||
16 | * |
||
17 | * @var \Psr\SimpleCache\CacheInterface |
||
18 | */ |
||
19 | private $cache = null; |
||
20 | |||
21 | /** |
||
22 | * Detected browscap version (read from INI file) |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | private $version = null; |
||
27 | |||
28 | /** |
||
29 | * Release date of the Browscap data (read from INI file) |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $releaseDate; |
||
34 | |||
35 | /** |
||
36 | * Type of the Browscap data (read from INI file) |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $type; |
||
41 | |||
42 | /** |
||
43 | * Constructor class, checks for the existence of (and loads) the cache and |
||
44 | * if needed updated the definitions |
||
45 | * |
||
46 | * @param \Psr\SimpleCache\CacheInterface $adapter |
||
47 | */ |
||
48 | 4 | public function __construct(CacheInterface $adapter) |
|
52 | |||
53 | /** |
||
54 | * Gets the version of the Browscap data |
||
55 | * |
||
56 | * @return int |
||
57 | */ |
||
58 | 2 | public function getVersion() : ?int |
|
72 | |||
73 | /** |
||
74 | * Gets the release date of the Browscap data |
||
75 | * |
||
76 | * @return string|null |
||
77 | */ |
||
78 | 1 | public function getReleaseDate() : ?string |
|
92 | |||
93 | /** |
||
94 | * Gets the type of the Browscap data |
||
95 | */ |
||
96 | 1 | public function getType() : ?string |
|
110 | |||
111 | /** |
||
112 | * Get an item. |
||
113 | * |
||
114 | * @param string $cacheId |
||
115 | * @param bool $withVersion |
||
116 | * @param bool &$success |
||
117 | * |
||
118 | * @return mixed Data on success, null on failure |
||
119 | */ |
||
120 | 3 | public function getItem(string $cacheId, bool $withVersion = true, ?bool &$success = null) |
|
156 | |||
157 | /** |
||
158 | * save the content into an php file |
||
159 | * |
||
160 | * @param string $cacheId The cache id |
||
161 | * @param mixed $content The content to store |
||
162 | * @param bool $withVersion |
||
163 | * |
||
164 | * @return bool whether the file was correctly written to the disk |
||
165 | */ |
||
166 | 3 | public function setItem(string $cacheId, $content, bool $withVersion = true) : bool |
|
186 | |||
187 | /** |
||
188 | * Test if an item exists. |
||
189 | * |
||
190 | * @param string $cacheId |
||
191 | * @param bool $withVersion |
||
192 | * |
||
193 | * @return bool |
||
194 | */ |
||
195 | public function hasItem(string $cacheId, bool $withVersion = true) : bool |
||
210 | |||
211 | /** |
||
212 | * Remove an item. |
||
213 | * |
||
214 | * @param string $cacheId |
||
215 | * @param bool $withVersion |
||
216 | * |
||
217 | * @return bool |
||
218 | */ |
||
219 | public function removeItem(string $cacheId, bool $withVersion = true) : bool |
||
233 | |||
234 | /** |
||
235 | * Flush the whole storage |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | public function flush() : bool |
||
243 | } |
||
244 |