Completed
Push — master ( 99d075...0c659c )
by Pavel
26:03
created

VoidEntityCache   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 77.27%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 60
ccs 17
cts 22
cp 0.7727
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A get() 0 6 1
A set() 0 4 1
A getConfiguration() 0 4 1
A getMetadata() 0 4 1
A logSkip() 0 6 1
A clear() 0 4 1
1
<?php
2
3
namespace Bankiru\Api\Doctrine\Cache;
4
5
use Bankiru\Api\Doctrine\EntityDataCacheInterface;
6
use Bankiru\Api\Doctrine\Mapping\ApiMetadata;
7
use Psr\Log\LoggerInterface;
8
use Psr\Log\NullLogger;
9
10
final class VoidEntityCache implements EntityDataCacheInterface
11
{
12
    /** @var  ApiMetadata */
13
    private $metadata;
14
    /**
15
     * @var LoggerInterface
16
     */
17
    private $logger;
18
19
    /**
20
     * VoidEntityCache constructor.
21
     *
22
     * @param ApiMetadata     $metadata
23
     * @param LoggerInterface $logger
24
     */
25 26
    public function __construct(ApiMetadata $metadata, LoggerInterface $logger = null)
26
    {
27 26
        $this->metadata = $metadata;
28 26
        $this->logger   = $logger ?: new NullLogger();
29 26
    }
30
31
    /** {@inheritdoc} */
32 13
    public function get(array $identifier)
33
    {
34 13
        $this->logSkip();
35
36 13
        return null;
37
    }
38
39
    /** {@inheritdoc} */
40 13
    public function set(array $identifier, $data)
41
    {
42 13
        $this->logSkip();
43 13
    }
44
45
    /** {@inheritdoc} */
46
    public function getConfiguration()
47
    {
48
        return CacheConfiguration::disabled();
49
    }
50
51
    /** {@inheritdoc} */
52 13
    public function getMetadata()
53
    {
54 13
        return $this->metadata;
55
    }
56
57 13
    private function logSkip()
58
    {
59 13
        $this->logger->debug(
60 13
            sprintf('Skipping entity cache for %s: not configured', $this->getMetadata()->getName())
61 13
        );
62 13
    }
63
64
    /** {@inheritdoc} */
65
    public function clear(array $identifier)
66
    {
67
        $this->logSkip();
68
    }
69
}
70