Completed
Pull Request — master (#10)
by
unknown
12:33
created

BlackholeCacheItemDecorator::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace MovingImage\Bundle\VMProApiBundle\Decorator;
4
5
use Psr\Cache\CacheItemInterface;
6
7
/**
8
 * Decorator that wraps around any CacheItemInterface implementation
9
 * and overrides the `isHit` method by always returning false.
10
 * Therefore, this is a CacheItem implementation useful for forcing cache to be refreshed.
11
 */
12
class BlackholeCacheItemDecorator implements CacheItemInterface
13
{
14
    /**
15
     * Decorated CacheItem implementation.
16
     *
17
     * @var CacheItemInterface
18
     */
19
    private $cacheItem;
20
21
    /**
22
     * @param CacheItemInterface $cacheItem
23
     */
24 8
    public function __construct(CacheItemInterface $cacheItem)
25
    {
26 8
        $this->cacheItem = $cacheItem;
27 8
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getKey()
33
    {
34
        return $this->cacheItem->getKey();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function get()
41
    {
42
        return $this->cacheItem->get();
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 2
    public function isHit()
49
    {
50 2
        return false;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function set($value)
57
    {
58
        return $this->cacheItem->set($value);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function expiresAt($expiration)
65
    {
66
        return $this->cacheItem->expiresAt($expiration);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function expiresAfter($time)
73
    {
74
        return $this->cacheItem->expiresAfter($time);
75
    }
76
77
    /**
78
     * Returns the decorated CacheItemInterface implementation.
79
     *
80
     * @return CacheItemInterface
81
     */
82 2
    public function getDecoratedItem()
83
    {
84 2
        return $this->cacheItem;
85
    }
86
}
87