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
Pull Request — master (#278)
by Matthew
08:28
created

ResponseCacheRepository::has()   A

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 1
1
<?php
2
3
namespace Spatie\ResponseCache;
4
5
use Illuminate\Cache\Repository;
6
use Spatie\ResponseCache\Serializers\Serializer;
7
use Symfony\Component\HttpFoundation\Response;
8
9
class ResponseCacheRepository
10
{
11
    /**
12
     * @var Repository
13
     */
14
    protected $cache;
15
16
    /**
17
     * @var Serializer
18
     */
19
    protected $responseSerializer;
20
21
    public function __construct(Serializer $responseSerializer, Repository $cache)
22
    {
23
        $this->cache = $cache;
24
25
        $this->responseSerializer = $responseSerializer;
26
    }
27
28
    /**
29
     * @param string $key
30
     * @param \Symfony\Component\HttpFoundation\Response $response
31
     * @param \DateTime|int $seconds
32
     */
33
    public function put(string $key, $response, $seconds)
34
    {
35
        $this->cache->put($key, $this->responseSerializer->serialize($response), is_numeric($seconds) ? now()->addSeconds($seconds) : $seconds);
36
    }
37
38
    public function has(string $key): bool
39
    {
40
        return $this->cache->has($key);
41
    }
42
43
    public function get(string $key): Response
44
    {
45
        return $this->responseSerializer->unserialize($this->cache->get($key));
46
    }
47
48
    public function clear()
49
    {
50
        $this->cache->clear();
51
    }
52
53
    public function forget(string $key): bool
54
    {
55
        return $this->cache->forget($key);
56
    }
57
58
    public function tags(array $tags): self
59
    {
60
        return new self($this->responseSerializer, $this->cache->tags($tags));
61
    }
62
}
63