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 ( b0fbea...fc60b7 )
by Nicholas
07:21
created

Container::offsetUnset()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace UCD\Console\Application;
4
5
use Pimple\Container as BaseContainer;
6
7
class Container extends BaseContainer
8
{
9
    /**
10
     * @var array
11
     */
12
    private $prefixes = [];
13
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function offsetSet($id, $value)
18
    {
19
        parent::offsetSet($id, $value);
20
21
        $this->recordPrefix($id);
22
    }
23
24
    /**
25
     * @param string $id
26
     */
27
    private function recordPrefix($id)
28
    {
29
        $prefix = $this->extractPrefix($id);
30
31
        if (!$this->hasPrefix($prefix)) {
32
            $this->prefixes[$prefix] = [];
33
        }
34
35
        $this->prefixes[$prefix][$id] = true;
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41
    public function offsetUnset($id)
42
    {
43
        parent::offsetUnset($id);
44
45
        $prefix = $this->extractPrefix($id);
46
47
        if (isset($this->prefixes[$prefix][$id])) {
48
            unset($this->prefixes[$prefix][$id]);
49
        }
50
    }
51
52
    /**
53
     * @param string $prefix
54
     * @return bool
55
     */
56
    private function hasPrefix($prefix)
57
    {
58
        return array_key_exists($prefix, $this->prefixes);
59
    }
60
61
    /**
62
     * @param $id
63
     * @return mixed
64
     */
65
    private function extractPrefix($id)
66
    {
67
        $parts = explode('.', $id);
68
69
        return array_shift($parts);
70
    }
71
72
    /**
73
     * @param string $prefix
74
     * @return string[]
75
     */
76
    public function idsByPrefix($prefix)
77
    {
78
        if (!$this->hasPrefix($prefix)) {
79
            return [];
80
        }
81
82
        return array_keys($this->prefixes[$prefix]);
83
    }
84
}