-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Item.php
53 lines (44 loc) · 1.31 KB
/
Item.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Phpfastcache\Drivers\Phparray;
use Phpfastcache\Core\Item\{ExtendedCacheItemInterface, ItemBaseTrait};
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
use Phpfastcache\Drivers\Phparray\Driver as PhparrayDriver;
use Phpfastcache\Exceptions\{PhpfastcacheInvalidArgumentException};
/**
* Class Item
* @package phpFastCache\Drivers\Phparray
*/
class Item implements ExtendedCacheItemInterface
{
use ItemBaseTrait {
ItemBaseTrait::__construct as __BaseConstruct;
}
/**
* Item constructor.
* @param Driver $driver
* @param $key
* @throws PhpfastcacheInvalidArgumentException
*/
public function __construct(PhparrayDriver $driver, $key)
{
$this->__BaseConstruct($driver, $key);
}
/**
* @param ExtendedCacheItemPoolInterface $driver
* @return static
* @throws PhpfastcacheInvalidArgumentException
*/
public function setDriver(ExtendedCacheItemPoolInterface $driver)
{
if ($driver instanceof PhparrayDriver) {
$this->driver = $driver;
return $this;
}
throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
}
}