for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpWinTools\WmiScripting\Support\Cache;
use Psr\SimpleCache\CacheInterface;
use PhpWinTools\WmiScripting\Configuration\Config;
use PhpWinTools\WmiScripting\Exceptions\CacheInvalidArgumentException;
abstract class CacheDriver implements CacheInterface
{
protected $config;
protected $store;
public function __construct(Config $config = null)
$this->config = $config ?? Config::instance();
}
/**
* @param string $key
*
* @return bool
* @throws CacheInvalidArgumentException
*/
abstract public function has($key);
public function expired($key, $ttl = null): bool
$ttl
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function expired($key, /** @scrutinizer ignore-unused */ $ttl = null): bool
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$key
public function expired(/** @scrutinizer ignore-unused */ $key, $ttl = null): bool
return false;
public function valid($key, $ttl = null)
return $this->expired($key, $ttl) === false;
public function exists($key)
return $this->has($key);
public function doesNotExist($key)
return $this->exists($key) === false;
protected function validateKey($key)
if (is_string($key)) {
return $key;
throw new CacheInvalidArgumentException("{$key} is not a valid key");
public function canGet($key)
try {
return $this->has($key) || $this->valid($key);
} catch (CacheInvalidArgumentException $exception) {
public function canSet($key, $value)
$value
public function canSet($key, /** @scrutinizer ignore-unused */ $value)
return $this->validateKey($key) === $key;
public function canDelete($key)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.