Completed
Push — master ( be9660...707803 )
by Georges
16s queued 13s
created

ItemAbstract::setDriver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
/**
4
 *
5
 * This file is part of phpFastCache.
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For full copyright and license information, please see the docs/CREDITS.txt file.
10
 *
11
 * @author Khoa Bui (khoaofgod)  <[email protected]> https://www.phpfastcache.com
12
 * @author Georges.L (Geolim4)  <[email protected]>
13
 *
14
 */
15
declare(strict_types=1);
16
17
namespace Phpfastcache\Cluster;
18
19
use Phpfastcache\Core\Item\{ExtendedCacheItemInterface, ItemBaseTrait};
20
use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
21
use Phpfastcache\Exceptions\{PhpfastcacheInvalidArgumentException};
22
23
/**
24
 * Class ClusterItem
25
 * @package Phpfastcache\Cluster
26
 */
27
abstract class ItemAbstract implements ExtendedCacheItemInterface
28
{
29
    use ItemBaseTrait {
30
        ItemBaseTrait::__construct as __BaseConstruct;
31
    }
32
33
    /**
34
     * @param ExtendedCacheItemPoolInterface $driver
35
     * @return static
36
     * @throws PhpfastcacheInvalidArgumentException
37
     */
38
    public function setDriver(ExtendedCacheItemPoolInterface $driver)
39
    {
40
        if ($driver instanceof ClusterPoolInterface) {
41
            $this->driver = $driver;
42
43
            return $this;
44
        }
45
46
        throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
47
    }
48
}
49