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 ( 22e7f3...55e1e4 )
by Dmitri
02:43
created

RedisStorage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A remove() 0 3 1
A get() 0 7 2
A __construct() 0 3 1
A add() 0 3 1
A has() 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
use Predis\Client;
9
10
class RedisStorage implements Storage
11
{
12
    private $client;
13
14
    public function __construct(Client $client)
15
    {
16
        $this->client = $client;
17
    }
18
19
    public function has(string $key): bool
20
    {
21
        return (bool) $this->client->exists($key);
22
    }
23
24
    /**
25
     * @throws KeyNotFoundException
26
     */
27
    public function get(string $key): Key
28
    {
29
        if (null === $username = $this->client->get($key)) {
30
            throw new KeyNotFoundException();
31
        }
32
33
        return new Key($key, $username, $this->client->ttl($key));
34
    }
35
36
    public function add(Key $key): void
37
    {
38
        $this->client->setex((string) $key, $key->ttl(), $key->username());
39
    }
40
41
    public function remove(string $key): void
42
    {
43
        $this->client->del([$key]);
44
    }
45
}
46