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.

Json::clear()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Cache;
4
5
use function ExceptionalJSON\decode;
6
use function ExceptionalJSON\encode;
7
use React\Cache\CacheInterface;
8
use React\Promise\PromiseInterface;
9
10
final class Json implements CacheInterface
11
{
12
    /** @var CacheInterface */
13
    private $cache;
14
15
    /**
16
     * @param CacheInterface $cache
17
     */
18 10
    public function __construct(CacheInterface $cache)
19
    {
20 10
        $this->cache = $cache;
21 10
    }
22
23
    /**
24
     * @param  string           $key
25
     * @param  null             $default
26
     * @return PromiseInterface
27
     */
28 2
    public function get($key, $default = null)
29
    {
30
        return $this->cache->get($key, $default)->then(function ($result) use ($default) {
31 2
            if ($result === null || $result === $default) {
32 1
                return $result;
33
            }
34
35 1
            return decode($result, true);
36 2
        });
37
    }
38
39
    /**
40
     * @param  string           $key
41
     * @param  mixed            $value
42
     * @param  null             $ttl
43
     * @return PromiseInterface
44
     */
45 1
    public function set($key, $value, $ttl = null)
46
    {
47 1
        return $this->cache->set($key, encode($value), $ttl);
48
    }
49
50
    /**
51
     * @param  string           $key
52
     * @return PromiseInterface
53
     */
54 1
    public function delete($key)
55
    {
56 1
        return $this->cache->delete($key);
57
    }
58
59 2
    public function getMultiple(array $keys, $default = null)
60
    {
61
        return $this->cache->getMultiple($keys, $default)->then(function ($results) use ($default) {
62 2
            foreach ($results as $key => $result) {
63 2
                if ($result === null || $result === $default) {
64 1
                    continue;
65
                }
66
67 1
                $results[$key] = decode($result, true);
68
            }
69
70 2
            return $results;
71 2
        });
72
    }
73
74 1
    public function setMultiple(array $values, $ttl = null)
75
    {
76 1
        foreach ($values as $key => $value) {
77 1
            $values[$key] = encode($value);
78
        }
79
80 1
        return $this->cache->setMultiple($values, $ttl);
81
    }
82
83 1
    public function deleteMultiple(array $keys)
84
    {
85 1
        return $this->cache->deleteMultiple($keys);
86
    }
87
88 1
    public function clear()
89
    {
90 1
        return $this->cache->clear();
91
    }
92
93 1
    public function has($key)
94
    {
95 1
        return $this->cache->has($key);
96
    }
97
}
98