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 ( ba7cd4...25ae2a )
by Hilari
04:31
created

RedisCache::flush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Cmp\Cache\Infrastructure;
4
5
use Cmp\Cache\Domain\Cache;
6
use Cmp\Cache\Domain\ExceptionsException;
7
use Cmp\Cache\Domain\Exceptions\NotFoundException;
8
use Redis;
9
10
/**
11
 * Class RedisCache
12
 * 
13
 * A redis powered backend for caching
14
 *
15
 * @package Cmp\Cache\Infrastureture
16
 */
17
class RedisCache implements Cache
18
{
19
    /**
20
     * @var Redis
21
     */
22
    private $client;
23
24
    /**
25
     * RedisCache constructor.
26
     *
27
     * @param Redis $client
28
     */
29
    public function __construct(Redis $client)
30
    {
31
        $this->client = $client;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function delete($key)
38
    {
39
        $this->client->delete($key);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function set($key, $value, $timeToLive = 0)
46
    {
47
        if ($timeToLive > 0) {
48
            $this->client->setex($key, $timeToLive, $value);
49
        } else {
50
            $this->client->set($key, $value);
51
        }
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function has($key)
58
    {
59
        return $this->client->exists($key);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function get($key)
66
    {
67
        $value = $this->client->get($key);
68
69
        if (!$value && !$this->client->exists($key)) {
70
            throw new NotFoundException($key);
71
        }
72
73
        return $value;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function pull($key, $default = null)
80
    {
81
        try {
82
            return $this->get($key);
83
        } catch (NotFoundException $exception) {
84
            return $default;
85
        }
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function flush()
92
    {
93
        $this->client->flushDB();
94
    }
95
}
96