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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 59
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 4 1
A get() 0 7 2
A delete() 0 4 1
A __construct() 0 11 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