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.

ChainStorage::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Key\Storage;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Key;
8
9
final class ChainStorage implements Reader
10
{
11
    /**
12
     * @var Reader[]
13
     */
14
    private $items = [];
15
16
    public function __construct(array $items = [])
17
    {
18
        foreach ($items as $item) {
19
            $this->addStorage($item);
20
        }
21
    }
22
23
    public function addStorage(Reader $storage): void
24
    {
25
        $this->items[] = $storage;
26
    }
27
28
    public function has(string $key): bool
29
    {
30
        foreach ($this->items as $storage) {
31
            if ($storage->has($key)) {
32
                return true;
33
            }
34
        }
35
36
        return false;
37
    }
38
39
    public function get(string $key): Key
40
    {
41
        foreach ($this->items as $storage) {
42
            if ($storage->has($key)) {
43
                return $storage->get($key);
44
            }
45
        }
46
47
        throw new KeyNotFound();
48
    }
49
}
50