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.
Passed
Push — master ( 2207c6...e66e76 )
by Dmitri
02:14
created

InMemoryStorage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A get() 0 7 2
A __construct() 0 4 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 InMemoryStorage implements Reader
10
{
11
    private $data;
12
    private $ttl;
13
14
    public function __construct(array $data, int $ttl = 3600)
15
    {
16
        $this->data = $data;
17
        $this->ttl = $ttl;
18
    }
19
20
    public function has(string $key): bool
21
    {
22
        return (bool) array_search($key, $this->data);
23
    }
24
25
    public function get(string $key): Key
26
    {
27
        if (false === $identity = array_search($key, $this->data)) {
28
            throw new KeyNotFound();
29
        }
30
31
        return new Key($key, $identity, $this->ttl);
32
    }
33
}
34