Total Complexity | 4 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Coverage | 75% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class RuntimeStorage implements StorageInterface |
||
17 | { |
||
18 | /** @var array<string, \Nelexa\Doh\Storage\StorageItem> */ |
||
19 | private $cache = []; |
||
20 | |||
21 | 11 | public function get(string $domainName): ?StorageItem |
|
22 | { |
||
23 | 11 | $storageItem = $this->cache[$domainName] ?? null; |
|
24 | |||
25 | 11 | if ($storageItem !== null && $storageItem->getExpiredAt() < new \DateTimeImmutable()) { |
|
26 | unset($this->cache[$domainName]); |
||
27 | $storageItem = null; |
||
28 | } |
||
29 | |||
30 | 11 | return $storageItem; |
|
31 | } |
||
32 | |||
33 | 11 | public function save(string $domainName, StorageItem $item): void |
|
36 | } |
||
37 | } |
||
38 |