Completed
Pull Request — master (#2)
by Patryk
07:21
created

DoctrineCacheBridge::deleteAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
namespace KaLLoSz\Twig\Extension\Cache;
4
5
use Doctrine\Common\Cache\Cache;
6
7
/**
8
 * Class DoctrineCacheBridge
9
 */
10
class DoctrineCacheBridge implements CacheInterface
11
{
12
    /**
13
     * @var Cache
14
     */
15
    private $cache;
16
17
    /**
18
     * @param Cache $cache
19
     */
20
    public function __construct(Cache $cache)
21 28
    {
22
        $this->cache = $cache;
23 28
    }
24 28
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function get($id)
29 4
    {
30
        return $this->has($id) ? $this->cache->fetch($id) : false;
31 4
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function has($id)
37 20
    {
38
        return $this->cache->contains($id);
39 20
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function save($id, $data, $lifeTime = 0)
45 20
    {
46
        return $this->cache->save($id, $data, $lifeTime);
47 20
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function delete($id)
53 4
    {
54
        return $this->cache->delete($id);
55 4
    }
56
}
57