CacheMetadataExporter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 25
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A export() 0 10 1
A exportInstantiation() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping\Exporter;
6
7
use Doctrine\ORM\Mapping\CacheMetadata;
8
use const PHP_EOL;
9
use function implode;
10
use function sprintf;
11
use function str_repeat;
12
use function strtoupper;
13
14
class CacheMetadataExporter implements Exporter
15
{
16
    public const VARIABLE = '$cache';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function export($value, int $indentationLevel = 0) : string
22
    {
23
        /** @var CacheMetadata $value */
24
        $indentation     = str_repeat(self::INDENTATION, $indentationLevel);
25
        $objectReference = $indentation . self::VARIABLE;
26
        $lines           = [];
27
28
        $lines[] = $objectReference . ' = ' . $this->exportInstantiation($value);
29
30
        return implode(PHP_EOL, $lines);
31
    }
32
33
    protected function exportInstantiation(CacheMetadata $metadata) : string
34
    {
35
        return sprintf(
36
            'new Mapping\CacheMetadata(Mapping\CacheUsage::%s, "%s");',
37
            strtoupper($metadata->getUsage()),
38
            $metadata->getRegion()
39
        );
40
    }
41
}
42