Conditions | 5 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function get() : Response\GetDirectory { |
||
30 | |||
31 | if(array_key_exists($this->_index, $this->_responses)) { |
||
32 | return $this->_responses[$this->_index]; |
||
33 | } |
||
34 | $this->_responses[$this->_index] = null; |
||
35 | |||
36 | $cacheFile = Account::getCommonKeyDirectoryPath() . self::_FILE; |
||
37 | |||
38 | if(file_exists($cacheFile) && filemtime($cacheFile) > strtotime('-2 days')) { |
||
39 | |||
40 | $rawResponse = Connector\RawResponse::getFromString(file_get_contents($cacheFile)); |
||
41 | |||
42 | try { |
||
43 | return $this->_responses[$this->_index] = new Response\GetDirectory($rawResponse); |
||
44 | |||
45 | } catch(Exception\AbstractException $e) { |
||
46 | unlink($cacheFile); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | $request = new Request\GetDirectory(); |
||
51 | $response = $request->getResponse(); |
||
52 | $this->set($response); |
||
53 | |||
54 | return $response; |
||
55 | } |
||
64 | } |