Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.4661 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
56 | 2 | public function save($key, CacheEntry $data) |
|
57 | { |
||
58 | 2 | if ($this->lastItem && $this->lastItem->getKey() == $key) { |
|
59 | $item = $this->lastItem; |
||
60 | } else { |
||
61 | 2 | $item = $this->cachePool->getItem($key); |
|
62 | } |
||
63 | |||
64 | 2 | $this->lastItem = null; |
|
65 | |||
66 | 2 | $item->set($data); |
|
67 | |||
68 | 2 | $ttl = $data->getTTL(); |
|
69 | 2 | if ($ttl === 0) { |
|
70 | // No expiration |
||
71 | $item->expiresAfter(null); |
||
72 | } else { |
||
73 | 2 | $item->expiresAfter($ttl); |
|
74 | } |
||
75 | |||
76 | 2 | return $this->cachePool->save($item); |
|
77 | } |
||
78 | |||
93 |