This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
27
{
28
use ItemBaseTrait;
29
30
/**
31
* Item constructor.
32
* @param \phpFastCache\Drivers\Apc\Driver $driver
33
* @param $key
34
* @throws \InvalidArgumentException
35
*/
36
public function __construct(PredisDriver $driver, $key)
37
{
38
if (is_string($key)) {
39
$this->key = $key;
40
$this->driver = $driver;
41
$this->driver->setItem($this);
42
$this->expirationDate = new \DateTime();
43
} else {
44
throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key)));
45
}
46
}
47
48
/**
49
* @param ExtendedCacheItemPoolInterface $driver
50
* @throws \InvalidArgumentException
51
* @return static
52
*/
53
public function setDriver(ExtendedCacheItemPoolInterface $driver)
54
{
55
if ($driver instanceof PredisDriver) {
56
$this->driver = $driver;
57
58
return $this;
59
} else {
60
throw new \InvalidArgumentException('Invalid driver instance');
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.