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 ( 3f328f...c18bbe )
by Cees-Jan
11s
created

Json::delete()   A

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 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Cache;
4
5
use React\Cache\CacheInterface;
6
use React\Promise\PromiseInterface;
7
use function ExceptionalJSON\decode;
8
use function ExceptionalJSON\encode;
9
10
final class Json implements CacheInterface
11
{
12
    /** @var CacheInterface */
13
    private $cache;
14
15
    /**
16
     * @param CacheInterface $cache
17
     */
18 3
    public function __construct(CacheInterface $cache)
19
    {
20 3
        $this->cache = $cache;
21 3
    }
22
23
    /**
24
     * @param  string           $key
25
     * @param  null             $default
26
     * @return PromiseInterface
27
     */
28
    public function get($key, $default = null)
29
    {
30 1
        return $this->cache->get($key, $default)->then(function ($result) {
31 1
            return decode($result, true);
32 1
        });
33
    }
34
35
    /**
36
     * @param  string           $key
37
     * @param  mixed            $value
38
     * @param  null             $ttl
39
     * @return PromiseInterface
40
     */
41 1
    public function set($key, $value, $ttl = null)
42
    {
43 1
        return $this->cache->set($key, encode($value), $ttl);
44
    }
45
46
    /**
47
     * @param  string           $key
48
     * @return PromiseInterface
49
     */
50 1
    public function delete($key)
51
    {
52 1
        return $this->cache->delete($key);
53
    }
54
}
55