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.
Completed
Push — master ( 7bf065...13ae28 )
by Axel
02:07
created

CacheManager   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 61.11%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 54
ccs 11
cts 18
cp 0.6111
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 3 1
A __construct() 0 3 1
A getItem() 0 12 3
A getItemPool() 0 7 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 4
    public function __construct($options = []) {
19 4
        $this->options = $options;
20 4
    }
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
        }
58 3
        return $this->pools[$driver];
59
    }
60
}
61