1 | <?php |
||
6 | class CRemoteImage |
||
7 | { |
||
8 | /** |
||
9 | * Path to cache files. |
||
10 | */ |
||
11 | private $saveFolder = null; |
||
12 | |||
13 | |||
14 | |||
15 | /** |
||
16 | * Use cache or not. |
||
17 | */ |
||
18 | private $useCache = true; |
||
19 | |||
20 | |||
21 | |||
22 | /** |
||
23 | * HTTP object to aid in download file. |
||
24 | */ |
||
25 | private $http; |
||
26 | |||
27 | |||
28 | |||
29 | /** |
||
30 | * Status of the HTTP request. |
||
31 | */ |
||
32 | private $status; |
||
33 | |||
34 | |||
35 | |||
36 | /** |
||
37 | * Defalt age for cached items 60*60*24*7. |
||
38 | */ |
||
39 | private $defaultMaxAge = 604800; |
||
40 | |||
41 | |||
42 | |||
43 | /** |
||
44 | * Url of downloaded item. |
||
45 | */ |
||
46 | private $url; |
||
47 | |||
48 | |||
49 | |||
50 | /** |
||
51 | * Base name of cache file for downloaded item and name of image. |
||
52 | */ |
||
53 | private $fileName; |
||
54 | |||
55 | |||
56 | |||
57 | /** |
||
58 | * Filename for json-file with details of cached item. |
||
59 | */ |
||
60 | private $fileJson; |
||
61 | |||
62 | |||
63 | |||
64 | /** |
||
65 | * Cache details loaded from file. |
||
66 | */ |
||
67 | private $cache; |
||
68 | |||
69 | |||
70 | |||
71 | /** |
||
72 | * Get status of last HTTP request. |
||
73 | * |
||
74 | * @return int as status |
||
75 | */ |
||
76 | public function getStatus() |
||
80 | |||
81 | |||
82 | |||
83 | /** |
||
84 | * Get JSON details for cache item. |
||
85 | * |
||
86 | * @return array with json details on cache. |
||
87 | */ |
||
88 | public function getDetails() |
||
92 | |||
93 | |||
94 | |||
95 | /** |
||
96 | * Set the path to the cache directory. |
||
97 | * |
||
98 | * @param boolean $use true to use the cache and false to ignore cache. |
||
|
|||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function setCache($path) |
||
107 | |||
108 | |||
109 | |||
110 | /** |
||
111 | * Check if cache is writable or throw exception. |
||
112 | * |
||
113 | * @return $this |
||
114 | * |
||
115 | * @throws Exception if cahce folder is not writable. |
||
116 | */ |
||
117 | public function isCacheWritable() |
||
124 | |||
125 | |||
126 | |||
127 | /** |
||
128 | * Decide if the cache should be used or not before trying to download |
||
129 | * a remote file. |
||
130 | * |
||
131 | * @param boolean $use true to use the cache and false to ignore cache. |
||
132 | * |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function useCache($use = true) |
||
140 | |||
141 | |||
142 | |||
143 | /** |
||
144 | * Set header fields. |
||
145 | * |
||
146 | * @return $this |
||
147 | */ |
||
148 | public function setHeaderFields() |
||
165 | |||
166 | |||
167 | |||
168 | /** |
||
169 | * Save downloaded resource to cache. |
||
170 | * |
||
171 | * @return string as path to saved file or false if not saved. |
||
172 | */ |
||
173 | public function save() |
||
202 | |||
203 | |||
204 | |||
205 | /** |
||
206 | * Got a 304 and updates cache with new age. |
||
207 | * |
||
208 | * @return string as path to cached file. |
||
209 | */ |
||
210 | public function updateCacheDetails() |
||
226 | |||
227 | |||
228 | |||
229 | /** |
||
230 | * Download a remote file and keep a cache of downloaded files. |
||
231 | * |
||
232 | * @param string $url a remote url. |
||
233 | * |
||
234 | * @throws Exception when status code does not match 200 or 304. |
||
235 | * |
||
236 | * @return string as path to downloaded file or false if failed. |
||
237 | */ |
||
238 | public function download($url) |
||
270 | |||
271 | |||
272 | |||
273 | /** |
||
274 | * Get the path to the cached image file if the cache is valid. |
||
275 | * |
||
276 | * @return $this |
||
277 | */ |
||
278 | public function loadCacheDetails() |
||
287 | |||
288 | |||
289 | |||
290 | /** |
||
291 | * Get the path to the cached image file if the cache is valid. |
||
292 | * |
||
293 | * @return string as the path ot the image file or false if no cache. |
||
294 | */ |
||
295 | public function getCachedSource() |
||
315 | } |
||
316 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.