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 ( 2f12c3...e53ef5 )
by Hilari
02:46
created

RedisCache::pull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A RedisCache::delete() 0 4 1
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 set($key, $value, $timeToLive = 0)
38
    {
39
        if ($timeToLive > 0) {
40
            $this->client->setex($key, $timeToLive, $value);
41
        } else {
42
            $this->client->set($key, $value);
43
        }
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function has($key)
50
    {
51
        return $this->client->exists($key);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function demand($key)
58
    {
59
        $value = $this->client->get($key);
60
61
        if (!$value && !$this->client->exists($key)) {
62
            throw new NotFoundException($key);
63
        }
64
65
        return $value;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function get($key, $default = null)
72
    {
73
        try {
74
            return $this->demand($key);
75
        } catch (NotFoundException $exception) {
76
            return $default;
77
        }
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function delete($key)
84
    {
85
        $this->client->delete($key);
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    public function flush()
92
    {
93
        $this->client->flushDB();
94
    }
95
}
96