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.

RedisStorageAdapter::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Opensoft\Rollout\Storage;
4
5
/**
6
 * Storage adapter using Redis
7
 *
8
 * @author Woody Gilk <@shadowhand>
9
 */
10
class RedisStorageAdapter implements StorageInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    const DEFAULT_GROUP = 'rollout_feature';
16
17
    /**
18
     * @var object
19
     */
20
    private $redis;
21
22
    /**
23
     * @var string
24
     */
25
    private $group = self::DEFAULT_GROUP;
26
27
    public function __construct($redis, $group = null)
28
    {
29
        $this->redis = $redis;
30
31
        if ($group) {
32
            $this->group = $group;
33
        }
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function get($key)
40
    {
41
        $result = $this->redis->hget($this->group, $key);
42
43
        if (empty($result)) {
44
            return null;
45
        }
46
47
        $result = json_decode($result, true);
48
49
        if (JSON_ERROR_NONE !== json_last_error()) {
50
            return null;
51
        }
52
53
        return $result;
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59
    public function set($key, $value)
60
    {
61
        $this->redis->hset($this->group, $key, json_encode($value));
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function remove($key)
68
    {
69
        $this->redis->hdel($this->group, $key);
70
    }
71
}
72