1 | <?php |
||
46 | class BrowscapCache implements BrowscapCacheInterface |
||
47 | { |
||
48 | /** |
||
49 | * Path to the cache directory |
||
50 | * |
||
51 | * @var \WurflCache\Adapter\AdapterInterface |
||
52 | */ |
||
53 | private $cache = null; |
||
54 | |||
55 | /** |
||
56 | * Detected browscap version (read from INI file) |
||
57 | * |
||
58 | * @var int |
||
59 | */ |
||
60 | private $version = null; |
||
61 | |||
62 | /** |
||
63 | * Release date of the Browscap data (read from INI file) |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | private $releaseDate; |
||
68 | |||
69 | /** |
||
70 | * Constructor class, checks for the existence of (and loads) the cache and |
||
71 | * if needed updated the definitions |
||
72 | * |
||
73 | * @param \WurflCache\Adapter\AdapterInterface $adapter |
||
74 | * @param int $updateInterval |
||
75 | */ |
||
76 | 12 | public function __construct(AdapterInterface $adapter, $updateInterval = BrowscapCacheInterface::CACHE_LIVETIME) |
|
81 | |||
82 | /** |
||
83 | * Gets the version of the Browscap data |
||
84 | * |
||
85 | * @return int |
||
86 | */ |
||
87 | 4 | public function getVersion() |
|
101 | |||
102 | /** |
||
103 | * Gets the release date of the Browscap data |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getReleaseDate() |
||
121 | |||
122 | /** |
||
123 | * Get an item. |
||
124 | * |
||
125 | * @param string $cacheId |
||
126 | * @param bool $withVersion |
||
127 | * @param bool $success |
||
128 | * |
||
129 | * @return mixed Data on success, null on failure |
||
130 | */ |
||
131 | 4 | public function getItem($cacheId, $withVersion = true, & $success = null) |
|
162 | |||
163 | /** |
||
164 | * save the content into an php file |
||
165 | * |
||
166 | * @param string $cacheId The cache id |
||
167 | * @param mixed $content The content to store |
||
168 | * @param bool $withVersion |
||
169 | * |
||
170 | * @return boolean whether the file was correctly written to the disk |
||
171 | */ |
||
172 | 3 | public function setItem($cacheId, $content, $withVersion = true) |
|
186 | |||
187 | /** |
||
188 | * Test if an item exists. |
||
189 | * |
||
190 | * @param string $cacheId |
||
191 | * @param bool $withVersion |
||
192 | * |
||
193 | * @return bool |
||
194 | */ |
||
195 | 1 | public function hasItem($cacheId, $withVersion = true) |
|
203 | |||
204 | /** |
||
205 | * Remove an item. |
||
206 | * |
||
207 | * @param string $cacheId |
||
208 | * @param bool $withVersion |
||
209 | * |
||
210 | * @return bool |
||
211 | */ |
||
212 | public function removeItem($cacheId, $withVersion = true) |
||
220 | |||
221 | /** |
||
222 | * Flush the whole storage |
||
223 | * |
||
224 | * @return bool |
||
225 | */ |
||
226 | public function flush() |
||
230 | } |
||
231 |
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.