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 ( d1c731...ca9b69 )
by Axel
02:45
created

CacheManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 52.94%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 45
ccs 9
cts 17
cp 0.5294
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 3 1
A getItemPool() 0 7 2
A getItem() 0 12 3
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
    
13
    /**
14
     * @param \Psr\Cache\CacheItemInterface $item
15
     */
16 2
    public function save(CacheItemInterface $item) {
17 2
        $this->getItemPool($item->getDriver())->save($item);
18 2
    }
19
    
20
    /**
21
     * @param string $key
22
     * @param string $driver
23
     * @param int $ttl
24
     * @return \Psr\Cache\CacheItemInterface
25
     */
26
    public function getItem($key, $driver = null, $ttl = null) {
27
        $finalDriver = ($driver !== null) ? $driver : $this->defaultDriver;
28
        
29
        $pool = $this->getItemPool($finalDriver);
30
        $item = $pool->getItem($key);
31
        
32
        // In this case, the pool returned a new CacheItem
33
        if($item->get() === null) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
34
            $item->expiresAfter($ttl);
35
        }
36
        return $item;
37
    }
38
    
39
    /**
40
     * 
41
     * @param string $driver
42
     * @return Psr\Cache\CacheItemPoolInterface
43
     */
44 3
    public function getItemPool($driver) {
45 3
        if(!isset($this->pools[$driver])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
46 3
            $poolClass = 'PhpAbac\\Cache\\Pool\\' . ucfirst($driver) . 'CacheItemPool';
47 3
            $this->pools[$driver] = new $poolClass();
48 3
        }
49 3
        return $this->pools[$driver];
50
    }
51
}