Code Duplication    Length = 38-40 lines in 22 locations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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