Completed
Pull Request — master (#14)
by Pavel
04:00
created

VoidEntityCache::logSkip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 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 17
    public function __construct(ApiMetadata $metadata, LoggerInterface $logger = null)
26
    {
27 17
        $this->metadata = $metadata;
28 17
        $this->logger   = $logger ?: new NullLogger();
29 17
    }
30
31
    /** {@inheritdoc} */
32 10
    public function get(array $identifier)
33
    {
34 10
        $this->logSkip();
35
36 10
        return null;
37
    }
38
39
    /** {@inheritdoc} */
40 10
    public function set(array $identifier, $data)
41
    {
42 10
        $this->logSkip();
43 10
    }
44
45
    /** {@inheritdoc} */
46
    public function getConfiguration()
47
    {
48
        return CacheConfiguration::disabled();
49
    }
50
51
    /** {@inheritdoc} */
52 10
    public function getMetadata()
53
    {
54 10
        return $this->metadata;
55
    }
56
57 10
    private function logSkip()
58
    {
59 10
        $this->logger->debug(
60 10
            sprintf('Skipping entity cache for %s: not configured', $this->getMetadata()->getName())
61 10
        );
62 10
    }
63
}
64