Code Duplication    Length = 38-40 lines in 20 locations

src/phpFastCache/Drivers/Apc/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
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(ApcDriver $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 ApcDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Apcu/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apcu
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Apcu\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(ApcuDriver $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 ApcuDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Cookie/Item.php 1 location

@@ 26-65 (lines=40) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Cookie\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(CookieDriver $driver, $key)
37
    {
38
        if (is_string($key)) {
39
            $this->expirationDate = new \DateTime();
40
            $this->key = $key;
41
            $this->driver = $driver;
42
            $this->driver->setItem($this);
43
        } else {
44
            throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.',
45
              gettype($key)));
46
        }
47
    }
48
49
50
    /**
51
     * @param ExtendedCacheItemPoolInterface $driver
52
     * @throws \InvalidArgumentException
53
     * @return static
54
     */
55
    public function setDriver(ExtendedCacheItemPoolInterface $driver)
56
    {
57
        if ($driver instanceof CookieDriver) {
58
            $this->driver = $driver;
59
60
            return $this;
61
        } else {
62
            throw new \InvalidArgumentException('Invalid driver instance');
63
        }
64
    }
65
}

src/phpFastCache/Drivers/Couchbase/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Couchbase\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(CouchbaseDriver $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 CouchbaseDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Devfalse/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Devnull
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Devnull\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(DevnullDriver $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 DevnullDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Devnull/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Devnull
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Devnull\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(DevnullDriver $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 DevnullDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Devtrue/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Devtrue
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Devtrue\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(DevtrueDriver $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 DevtrueDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Files/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Files\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(FilesDriver $driver, $key)
37
    {
38
        if (is_string($key)) {
39
            $this->expirationDate = new \DateTime();
40
            $this->key = $key;
41
            $this->driver = $driver;
42
            $this->driver->setItem($this);
43
        } else {
44
            throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', get_class($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 FilesDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Leveldb/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Leveldb
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Leveldb\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(LeveldbDriver $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 LeveldbDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Memcache/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Memcache\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(MemcacheDriver $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 MemcacheDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Memcached/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Memcache\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(MemcachedDriver $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 MemcachedDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Mongodb/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Mongodb\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(MongodbDriver $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 MongodbDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Predis/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
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');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Redis/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Redis
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Redis\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(RedisDriver $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 RedisDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Sqlite/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Sqlite
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Sqlite\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(SqliteDriver $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 SqliteDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Ssdb/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Ssdb
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Ssdb\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(SsdbDriver $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 SsdbDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Wincache/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Wincache
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Wincache\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(WincacheDriver $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 WincacheDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Xcache/Item.php 1 location

@@ 26-63 (lines=38) @@
23
 * Class Item
24
 * @package phpFastCache\Drivers\Apc
25
 */
26
class Item implements ExtendedCacheItemInterface
27
{
28
    use ItemBaseTrait;
29
30
    /**
31
     * Item constructor.
32
     * @param \phpFastCache\Drivers\Xcache\Driver $driver
33
     * @param $key
34
     * @throws \InvalidArgumentException
35
     */
36
    public function __construct(XcacheDriver $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 XcacheDriver) {
56
            $this->driver = $driver;
57
58
            return $this;
59
        } else {
60
            throw new \InvalidArgumentException('Invalid driver instance');
61
        }
62
    }
63
}

src/phpFastCache/Drivers/Zenddisk/Item.php 1 location

@@ 25-62 (lines=38) @@
22
 * Class Item
23
 * @package phpFastCache\Drivers\Zenddisk
24
 */
25
class Item implements ExtendedCacheItemInterface
26
{
27
    use ItemBaseTrait;
28
29
    /**
30
     * Item constructor.
31
     * @param \phpFastCache\Drivers\Zenddisk\Driver $driver
32
     * @param $key
33
     * @throws \InvalidArgumentException
34
     */
35
    public function __construct(ZendDiskDriver $driver, $key)
36
    {
37
        if (is_string($key)) {
38
            $this->key = $key;
39
            $this->driver = $driver;
40
            $this->driver->setItem($this);
41
            $this->expirationDate = new \DateTime();
42
        } else {
43
            throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key)));
44
        }
45
    }
46
47
    /**
48
     * @param ExtendedCacheItemPoolInterface $driver
49
     * @throws \InvalidArgumentException
50
     * @return static
51
     */
52
    public function setDriver(ExtendedCacheItemPoolInterface $driver)
53
    {
54
        if ($driver instanceof ZendDiskDriver) {
55
            $this->driver = $driver;
56
57
            return $this;
58
        } else {
59
            throw new \InvalidArgumentException('Invalid driver instance');
60
        }
61
    }
62
}

src/phpFastCache/Drivers/Zendshm/Item.php 1 location

@@ 25-62 (lines=38) @@
22
 * Class Item
23
 * @package phpFastCache\Drivers\Zendshm
24
 */
25
class Item implements ExtendedCacheItemInterface
26
{
27
    use ItemBaseTrait;
28
29
    /**
30
     * Item constructor.
31
     * @param \phpFastCache\Drivers\Zendshm\Driver $driver
32
     * @param $key
33
     * @throws \InvalidArgumentException
34
     */
35
    public function __construct(ZendSHMDriver $driver, $key)
36
    {
37
        if (is_string($key)) {
38
            $this->key = $key;
39
            $this->driver = $driver;
40
            $this->driver->setItem($this);
41
            $this->expirationDate = new \DateTime();
42
        } else {
43
            throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key)));
44
        }
45
    }
46
47
    /**
48
     * @param ExtendedCacheItemPoolInterface $driver
49
     * @throws \InvalidArgumentException
50
     * @return static
51
     */
52
    public function setDriver(ExtendedCacheItemPoolInterface $driver)
53
    {
54
        if ($driver instanceof ZendSHMDriver) {
55
            $this->driver = $driver;
56
57
            return $this;
58
        } else {
59
            throw new \InvalidArgumentException('Invalid driver instance');
60
        }
61
    }
62
}