http://www.phpfastcache.com * @author Georges.L (Geolim4) * */ namespace phpFastCache\Drivers\Devfalse; use phpFastCache\Core\DriverAbstract; use phpFastCache\Entities\driverStatistic; use phpFastCache\Exceptions\phpFastCacheDriverCheckException; use phpFastCache\Exceptions\phpFastCacheDriverException; use Psr\Cache\CacheItemInterface; /** * Class Driver * @package phpFastCache\Drivers */ class Driver extends DriverAbstract { /** * Driver constructor. * @param array $config * @throws phpFastCacheDriverException */ public function __construct(array $config = []) { $this->setup($config); if (!$this->driverCheck()) { throw new phpFastCacheDriverCheckException(sprintf(self::DRIVER_CHECK_FAILURE, $this->getDriverName())); } } /** * @return bool */ public function driverCheck() { return true; } /** * @param \Psr\Cache\CacheItemInterface $item * @return mixed * @throws \InvalidArgumentException */ protected function driverWrite(CacheItemInterface $item) { /** * Check for Cross-Driver type confusion */ if ($item instanceof Item) { return true; } else { throw new \InvalidArgumentException('Cross-Driver type confusion detected'); } } /** * @param \Psr\Cache\CacheItemInterface $item * @return array [ * 'd' => 'THE ITEM DATA' * 't' => 'THE ITEM DATE EXPIRATION' * 'g' => 'THE ITEM TAGS' * ] */ protected function driverRead(CacheItemInterface $item) { return [ self::DRIVER_DATA_WRAPPER_INDEX => false, self::DRIVER_TAGS_WRAPPER_INDEX => [], self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), ]; } /** * @param \Psr\Cache\CacheItemInterface $item * @return bool * @throws \InvalidArgumentException */ protected function driverDelete(CacheItemInterface $item) { /** * Check for Cross-Driver type confusion */ if ($item instanceof Item) { return true; } else { throw new \InvalidArgumentException('Cross-Driver type confusion detected'); } } /** * @return bool */ protected function driverClear() { return true; } /** * @return bool */ protected function driverConnect() { return true; } /******************** * * PSR-6 Extended Methods * *******************/ /** * @return driverStatistic */ public function getStats() { $stat = new driverStatistic(); $stat->setInfo('[Devfalse] A void info string') ->setSize(0) ->setData(implode(', ', array_keys($this->itemInstances))) ->setRawData(false); return $stat; } }