GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CacheManager::getItemPool()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace PhpAbac\Manager;
4
5
use Psr\Cache\CacheItemInterface;
6
7
class CacheManager {
8
    /** @var string **/
9
    protected $defaultDriver = 'memory';
10
    /** @var array **/
11
    protected $pools;
12
    /** @var array **/
13
    protected $options;
14
15
    /**
16
     * @param array $options
17
     */
18 7
    public function __construct($options = []) {
19 7
        $this->options = $options;
20 7
    }
21
22
    /**
23
     * @param \Psr\Cache\CacheItemInterface $item
24
     */
25 2
    public function save(CacheItemInterface $item) {
26 2
        $this->getItemPool($item->getDriver())->save($item);
27 2
    }
28
29
    /**
30
     * @param string $key
31
     * @param string $driver
32
     * @param int $ttl
33
     * @return \Psr\Cache\CacheItemInterface
34
     */
35
    public function getItem($key, $driver = null, $ttl = null) {
36
        $finalDriver = ($driver !== null) ? $driver : $this->defaultDriver;
37
38
        $pool = $this->getItemPool($finalDriver);
39
        $item = $pool->getItem($key);
40
41
        // In this case, the pool returned a new CacheItem
42
        if($item->get() === null) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
43
            $item->expiresAfter($ttl);
44
        }
45
        return $item;
46
    }
47
48
    /**
49
     *
50
     * @param string $driver
51
     * @return Psr\Cache\CacheItemPoolInterface
52
     */
53 3
    public function getItemPool($driver) {
54 3
        if(!isset($this->pools[$driver])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
55 3
            $poolClass = 'PhpAbac\\Cache\\Pool\\' . ucfirst($driver) . 'CacheItemPool';
56 3
            $this->pools[$driver] = new $poolClass($this->options);
57 3
        }
58 3
        return $this->pools[$driver];
59
    }
60
}
61