1 | <?php |
||
11 | final class BrowscapCache implements BrowscapCacheInterface |
||
12 | { |
||
13 | /** |
||
14 | * Path to the cache directory |
||
15 | * |
||
16 | * @var \WurflCache\Adapter\AdapterInterface |
||
17 | */ |
||
18 | private $cache = null; |
||
19 | |||
20 | /** |
||
21 | * Detected browscap version (read from INI file) |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | private $version = null; |
||
26 | |||
27 | /** |
||
28 | * Release date of the Browscap data (read from INI file) |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $releaseDate; |
||
33 | |||
34 | /** |
||
35 | * Type of the Browscap data (read from INI file) |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $type; |
||
40 | |||
41 | /** |
||
42 | * Constructor class, checks for the existence of (and loads) the cache and |
||
43 | * if needed updated the definitions |
||
44 | * |
||
45 | * @param \WurflCache\Adapter\AdapterInterface $adapter |
||
46 | */ |
||
47 | 5 | public function __construct(AdapterInterface $adapter) |
|
51 | |||
52 | /** |
||
53 | * Gets the version of the Browscap data |
||
54 | * |
||
55 | * @return int |
||
56 | */ |
||
57 | 2 | public function getVersion() : ?int |
|
71 | |||
72 | /** |
||
73 | * Gets the release date of the Browscap data |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 1 | public function getReleaseDate() : string |
|
91 | |||
92 | /** |
||
93 | * Gets the type of the Browscap data |
||
94 | */ |
||
95 | 1 | public function getType() : ?string |
|
109 | |||
110 | /** |
||
111 | * Get an item. |
||
112 | * |
||
113 | * @param string $cacheId |
||
114 | * @param bool $withVersion |
||
115 | * @param bool $success |
||
116 | * |
||
117 | * @return mixed Data on success, null on failure |
||
118 | */ |
||
119 | 3 | public function getItem(string $cacheId, bool $withVersion = true, ?bool & $success = null) |
|
150 | |||
151 | /** |
||
152 | * save the content into an php file |
||
153 | * |
||
154 | * @param string $cacheId The cache id |
||
155 | * @param mixed $content The content to store |
||
156 | * @param bool $withVersion |
||
157 | * |
||
158 | * @return bool whether the file was correctly written to the disk |
||
159 | */ |
||
160 | 3 | public function setItem(string $cacheId, $content, bool $withVersion = true) : bool |
|
174 | |||
175 | /** |
||
176 | * Test if an item exists. |
||
177 | * |
||
178 | * @param string $cacheId |
||
179 | * @param bool $withVersion |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | public function hasItem(string $cacheId, bool $withVersion = true) : bool |
||
191 | |||
192 | /** |
||
193 | * Remove an item. |
||
194 | * |
||
195 | * @param string $cacheId |
||
196 | * @param bool $withVersion |
||
197 | * |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function removeItem(string $cacheId, bool $withVersion = true) : bool |
||
208 | |||
209 | /** |
||
210 | * Flush the whole storage |
||
211 | * |
||
212 | * @return bool |
||
213 | */ |
||
214 | public function flush() : bool |
||
218 | } |
||
219 |
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.