| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class Psr16CacheStore implements Store |
||
| 14 | { |
||
| 15 | private CacheInterface $cache; |
||
| 16 | |||
| 17 | 12 | public function __construct(CacheInterface $cache) |
|
| 20 | 12 | } |
|
| 21 | |||
| 22 | 10 | public function hit(Key $key): Counter |
|
| 23 | { |
||
| 24 | 10 | $counter = $this->status($key)->addHit(); |
|
| 25 | |||
| 26 | 10 | $this->cache->set((string) $key, $counter, $counter->resetsIn()); |
|
| 27 | |||
| 28 | 10 | return $counter; |
|
| 29 | } |
||
| 30 | |||
| 31 | 11 | public function status(Key $key): Counter |
|
| 32 | { |
||
| 33 | 11 | $counter = $this->cache->get((string) $key); |
|
| 34 | |||
| 35 | 11 | if (!$counter instanceof Counter) { |
|
| 36 | 11 | $counter = $key->createCounter(); |
|
| 37 | } |
||
| 38 | |||
| 39 | 11 | return $counter; |
|
| 40 | } |
||
| 41 | |||
| 42 | 11 | public function reset(Key $key): void |
|
| 45 | 11 | } |
|
| 46 | } |
||
| 47 |