Completed
Push — master ( b45a00...0b0210 )
by Patryk
04:17
created

DoctrineCacheBridge::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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