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 ( 45e0c6...234875 )
by Hilari
02:43
created

RedisCache::set()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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