Conditions | 6 |
Paths | 5 |
Total Lines | 24 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
55 | 7 | public function getAll(): array |
|
56 | { |
||
57 | 7 | if ($this->data !== null) { |
|
58 | 4 | return $this->data; |
|
59 | } |
||
60 | |||
61 | // retrieves from cache |
||
62 | 7 | if ($this->enableCache && ($this->data = $this->cache->get($this->cacheKey)) !== false) { |
|
63 | 3 | return $this->data; |
|
64 | } |
||
65 | |||
66 | // retrieves all data |
||
67 | 7 | $this->data = $this->load(); |
|
68 | |||
69 | // cache |
||
70 | 7 | if ($this->enableCache) { |
|
71 | 5 | $lock = $this->cacheKey; |
|
72 | // acquire lock avoid concurrence |
||
73 | 5 | if ($this->mutex->acquire($lock, 0)) { |
|
74 | 5 | $this->cache->set($this->cacheKey, $this->data, $this->duration); |
|
75 | } |
||
76 | } |
||
77 | |||
78 | 7 | return $this->data; |
|
79 | } |
||
95 |