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   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 9 3
A __construct() 0 4 2
A get() 0 9 3
A addStorage() 0 3 1
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