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

ItemAbstract   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A setDriver() 0 9 2
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