| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class TestCache implements PhpObjectDecoratorCacheInterface |
||
| 8 | { |
||
| 9 | |||
| 10 | private array $cache = []; |
||
| 11 | |||
| 12 | private bool $enabled = true; |
||
| 13 | |||
| 14 | public function get(string $key, callable $provider): string |
||
| 15 | { |
||
| 16 | if (!$this->contains($key)) { |
||
| 17 | $value = $provider(); |
||
| 18 | $this->cache[$key] = $value; |
||
| 19 | |||
| 20 | return $value; |
||
| 21 | } |
||
| 22 | |||
| 23 | return $this->cache[$key]; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function isEnabled(): bool |
||
| 29 | } |
||
| 30 | |||
| 31 | public function contains(string $key) |
||
| 32 | { |
||
| 33 | return array_key_exists($key, $this->cache); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function setEnabled(bool $enabled): void |
||
| 39 | } |
||
| 40 | |||
| 41 | } |