| Total Complexity | 6 | 
| Total Lines | 47 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php  | 
            ||
| 14 | final class CacheItems  | 
            ||
| 15 | { | 
            ||
| 16 | /**  | 
            ||
| 17 | * @var array<string, CacheItem>  | 
            ||
| 18 | */  | 
            ||
| 19 | private array $items = [];  | 
            ||
| 20 | |||
| 21 | /**  | 
            ||
| 22 | * Checks whether the dependency has been changed or whether the cache expired.  | 
            ||
| 23 | *  | 
            ||
| 24 | * @param string $key The key that identifies the cache item.  | 
            ||
| 25 | * @param float $beta The value for calculating the range that is used for "Probably early expiration" algorithm.  | 
            ||
| 26 | * @param CacheInterface $cache The actual cache handler.  | 
            ||
| 27 | *  | 
            ||
| 28 | * @return bool Whether the dependency has been changed or whether the cache expired.  | 
            ||
| 29 | */  | 
            ||
| 30 | 50 | public function expired(string $key, float $beta, CacheInterface $cache): bool  | 
            |
| 31 |     { | 
            ||
| 32 | 50 | return isset($this->items[$key]) && $this->items[$key]->expired($beta, $cache);  | 
            |
| 33 | }  | 
            ||
| 34 | |||
| 35 | /**  | 
            ||
| 36 | * Adds or updates a cache item.  | 
            ||
| 37 | *  | 
            ||
| 38 | * @param CacheItem $item The cache item.  | 
            ||
| 39 | */  | 
            ||
| 40 | 43 | public function set(CacheItem $item): void  | 
            |
| 41 |     { | 
            ||
| 42 | 43 | $key = $item->key();  | 
            |
| 43 | |||
| 44 | 43 |         if (!isset($this->items[$key])) { | 
            |
| 45 | 43 | $this->items[$key] = $item;  | 
            |
| 46 | 43 | return;  | 
            |
| 47 | }  | 
            ||
| 48 | |||
| 49 | 7 | $this->items[$key]->update($item->expiry(), $item->dependency());  | 
            |
| 50 | 7 | }  | 
            |
| 51 | |||
| 52 | /**  | 
            ||
| 53 | * Removes a cache item with the specified key.  | 
            ||
| 54 | *  | 
            ||
| 55 | * @param string $key The key that identifies the cache item.  | 
            ||
| 56 | */  | 
            ||
| 57 | 13 | public function remove(string $key): void  | 
            |
| 61 | }  | 
            ||
| 62 | 13 | }  | 
            |
| 63 | }  | 
            ||
| 64 |