BlackholeCacheItemDecorator   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

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