Conditions | 5 |
Paths | 6 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 16.3777 |
Changes | 0 |
1 | <?php |
||
29 | 2 | function getCache($name, $expire=null){ |
|
30 | 2 | if(!is_null($expire)){ |
|
31 | $this->expire = $expire; |
||
32 | } |
||
33 | |||
34 | 2 | $cached = $this->readFile($name); |
|
35 | |||
36 | if($cached !== false){ |
||
37 | $data = json_decode($cached, true); |
||
38 | $cache_time = $data['server_time']; |
||
39 | $now_time = time(); |
||
40 | if($now_time >= $cache_time && $now_time <= ($cache_time + $this->expire)){ |
||
41 | return $data; |
||
42 | } |
||
43 | } |
||
44 | return false; |
||
45 | } |
||
46 | |||
73 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.