for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Src/Cache/AbstractCache.php
*
* @package Ds\Cache
* @subpackage Cache
* @author Dan Smith <[email protected]>
* @version v.1 (20/03/2017)
* @copyright Copyright (c) 2017, Dan Smith
*/
namespace Ds\Cache;
use Ds\Cache\Storage\NullStorage;
* Abstract Cache Component
abstract class AbstractCache implements CacheInterface
{
* @var CacheStorageInterface Cache Storage
protected $cache;
* Creates a new instance of Cache with CacheStorageInterface.
* @param CacheStorageInterface|null $cacheStorage
public function __construct(CacheStorageInterface $cacheStorage = null)
$this->cache = $cacheStorage;
if ($cacheStorage === null) {
$this->cache = new NullStorage();
}
* Create new instance with $CacheStorage
* @param CacheStorageInterface $cacheStorage
* @return CacheInterface
public function withCacheStorage(CacheStorageInterface $cacheStorage)
$new = clone $this;
$new->cache = $cacheStorage;
return $new;
* Get Cache Storage
* @return CacheStorageInterface
public function getCacheStorage()
return $this->cache;