| Total Complexity | 6 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class Psr6CacheStore implements Store |
||
| 15 | { |
||
| 16 | private CacheItemPoolInterface $cache; |
||
| 17 | |||
| 18 | 12 | public function __construct(CacheItemPoolInterface $cache) |
|
| 19 | { |
||
| 20 | 12 | $this->cache = $cache; |
|
| 21 | 12 | } |
|
| 22 | |||
| 23 | 10 | public function hit(Key $key): Counter |
|
| 24 | { |
||
| 25 | 10 | $item = $this->getNormalizedItem($key); |
|
| 26 | |||
| 27 | /** @var Counter $counter */ |
||
| 28 | 10 | $counter = $item->get()->addHit(); |
|
| 29 | |||
| 30 | 10 | $item->set($counter); |
|
| 31 | 10 | $item->expiresAfter($counter->resetsIn()); |
|
| 32 | 10 | $this->cache->save($item); |
|
| 33 | |||
| 34 | 10 | return $counter; |
|
| 35 | } |
||
| 36 | |||
| 37 | 3 | public function status(Key $key): Counter |
|
| 38 | { |
||
| 39 | 3 | return $this->getNormalizedItem($key)->get(); |
|
| 40 | } |
||
| 41 | |||
| 42 | 11 | public function reset(Key $key): void |
|
| 45 | 11 | } |
|
| 46 | |||
| 47 | 11 | private function getNormalizedItem(Key $key): CacheItemInterface |
|
| 56 | } |
||
| 57 | } |
||
| 58 |