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.

DoctrineCache::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-07-28
7
 *
8
 */
9
10
namespace Chapi\Component\Cache;
11
12
use Doctrine\Common\Cache\Cache;
13
14
class DoctrineCache implements CacheInterface
15
{
16
    /**
17
     * @var Cache
18
     */
19
    private $doctrineCache;
20
21
    /**
22
     * @var string
23
     */
24
    private $cachePrefix = '';
25
26
    /**
27
     * @param Cache $doctrineCache
28
     */
29 6
    public function __construct(
30
        Cache $doctrineCache,
31
        $cachePrefix
32
    ) {
33 6
        $this->doctrineCache = $doctrineCache;
34 6
        $this->cachePrefix = substr(
35 6
            md5($cachePrefix),
36 6
            0,
37 6
            6
38 6
        ) . '.';
39 6
    }
40
41
    /**
42
     * @param string $key
43
     * @param mixed $value
44
     * @param int $ttl
45
     * @return bool
46
     */
47 2
    public function set($key, $value, $ttl = 0)
48
    {
49 2
        return $this->doctrineCache->save($this->cachePrefix . $key, $value, $ttl);
50
    }
51
52
    /**
53
     * @param string $key
54
     * @return mixed|null
55
     */
56 2
    public function get($key)
57
    {
58 2
        return ($this->doctrineCache->contains($this->cachePrefix . $key))
59 1
            ? $this->doctrineCache->fetch($this->cachePrefix . $key)
60 2
            : null
61
        ;
62
    }
63
64
    /**
65
     * @param string $key
66
     * @return bool
67
     */
68 2
    public function delete($key)
69
    {
70 2
        return $this->doctrineCache->delete($this->cachePrefix . $key);
71
    }
72
}
73