for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Chubbyphp\Model\StorageCache;
final class ArrayStorageCache implements StorageCacheInterface
{
/**
* @var array
*/
private $cache = [];
* @param array $cache
public function __construct(array $cache = [])
$this->cache = $cache;
}
* @param string $id
* @param array $entry
*
* @return StorageCacheInterface
public function set(string $id, array $entry): StorageCacheInterface
$this->cache[$id] = $entry;
return $this;
* @return bool
public function has(string $id): bool
return array_key_exists($id, $this->cache);
* @return array
* @throws EntryNotFoundException
public function get(string $id)
if (!$this->has($id)) {
throw EntryNotFoundException::fromId($id);
return $this->cache[$id];
public function remove(string $id): StorageCacheInterface
unset($this->cache[$id]);
public function clear(): StorageCacheInterface
$this->cache = [];