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.

MemoryCacheItemPool::deleteItem()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 8
cp 0.75
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 6
nc 4
nop 1
crap 3.1406
1
<?php
2
3
namespace PhpAbac\Cache\Pool;
4
5
use Psr\Cache\CacheItemPoolInterface;
6
use Psr\Cache\CacheItemInterface;
7
8
use PhpAbac\Cache\Item\MemoryCacheItem;
9
10
class MemoryCacheItemPool implements CacheItemPoolInterface {
11
    /** @var array **/
12
    protected $items;
13
    /** @var array **/
14
    protected $deferredItems;
15
    /**
16
     * {@inheritdoc}
17
     */
18 2
    public function deleteItem($key) {
19 2
        if(isset($this->items[$key])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
20 2
            unset($this->items[$key]);
21 2
        }
22 2
        if(isset($this->deferredItems[$key])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
23
            unset($this->deferredItems[$key]);
24
        }
25 2
        return true;
26
    }
27
    
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    public function deleteItems(array $keys) {
32 1
        foreach($keys as $key) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
33 1
            if(!$this->deleteItem($key)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
34
                return false;
35
            }
36 1
        }
37 1
        return true;
38
    }
39
    
40
    /**
41
     * {@inheritdoc}
42
     */
43 9
    public function save(CacheItemInterface $item) {
44 9
        $this->items[$item->getKey()] = $item;
45
        
46 9
        return true;
47
    }
48
    
49
    /**
50
     * {@inheritdoc}
51
     */
52 2
    public function saveDeferred(CacheItemInterface $item) {
53 2
        $this->deferredItems[$item->getKey()] = $item;
54
        
55 2
        return true;
56
    }
57
    
58
    /**
59
     * {@inheritdoc}
60
     */
61 2
    public function commit() {
62 2
        foreach($this->deferredItems as $key => $item) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
63 2
            $this->items[$key] = $item;
64 2
            unset($this->deferredItems[$key]);
65 2
        }
66 2
        return true;
67
    }
68
    
69
    /**
70
     * {@inheritdoc}
71
     */
72 13
    public function hasItem($key) {
73 13
        return isset($this->items[$key]);
74
    }
75
    
76
    /**
77
     * {@inheritdoc}
78
     */
79 9
    public function getItem($key) {
80 9
        if(!$this->hasItem($key)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
81 4
            return new MemoryCacheItem($key);
82
        }
83 7
        return $this->items[$key];
84
    }
85
    
86
    /**
87
     * {@inheritdoc}
88
     */
89 3
    public function getItems(array $keys = array()) {
90 3
        $items = [];
91 3
        foreach($keys as $key) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
92 3
            if($this->hasItem($key)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
93 3
                $items[$key] = $this->getItem($key);
94 3
            }
95 3
        }
96 3
        return $items;
97
    }
98
    
99
    /**
100
     * {@inheritdoc}
101
     */
102 1
    public function clear() {
103 1
        $this->items = [];
104 1
        $this->deferredItems = [];
105 1
        return true;
106
    }
107
}