FieldMetadataExporter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 34
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A export() 0 12 1
A exportInstantiation() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping\Exporter;
6
7
use Doctrine\ORM\Mapping\ColumnMetadata;
8
use Doctrine\ORM\Mapping\FieldMetadata;
9
use const PHP_EOL;
10
use function assert;
11
use function implode;
12
use function ltrim;
13
use function sprintf;
14
use function str_repeat;
15
16
class FieldMetadataExporter extends LocalColumnMetadataExporter
17
{
18
    public const VARIABLE = '$property';
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function export($value, int $indentationLevel = 0) : string
24
    {
25
        /** @var FieldMetadata $value */
26
        $variableExporter = new VariableExporter();
27
        $indentation      = str_repeat(self::INDENTATION, $indentationLevel);
28
        $objectReference  = $indentation . self::VARIABLE;
29
30
        $lines   = [];
31
        $lines[] = parent::export($value, $indentationLevel);
32
        $lines[] = $objectReference . '->setVersioned(' . ltrim($variableExporter->export($value->isVersioned(), $indentationLevel + 1)) . ');';
33
34
        return implode(PHP_EOL, $lines);
35
    }
36
37
    protected function exportInstantiation(ColumnMetadata $metadata) : string
38
    {
39
        assert($metadata instanceof FieldMetadata);
40
41
        $lines   = [];
42
        $lines[] = sprintf(
43
            'new Mapping\FieldMetadata("%s", "%s", Type::getType("%s"));',
44
            $metadata->getName(),
45
            $metadata->getColumnName(),
46
            $metadata->getTypeName()
47
        );
48
49
        return implode(PHP_EOL, $lines);
50
    }
51
}
52