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::getItem()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.4285
cc 3
eloc 7
nc 4
nop 3
crap 12
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
}