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

BlackholeCacheItemDecorator   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 41.18%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 75
ccs 7
cts 17
cp 0.4118
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getKey() 0 4 1
A get() 0 4 1
A isHit() 0 4 1
A set() 0 4 1
A expiresAt() 0 4 1
A expiresAfter() 0 4 1
A getDecoratedItem() 0 4 1
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