Failed Conditions
Push — master ( ddb3cd...4476ec )
by Marco
11:47
created

MappedSuperClassMetadata::isVersioned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
/**
8
 * Class MappedSuperClassMetadata
9
 */
10
class MappedSuperClassMetadata extends ComponentMetadata
11
{
12
    /**
13
     * @var string|null
14
     */
15
    protected $customRepositoryClassName;
16
17
    /**
18
     * @var Property|null
19
     */
20
    protected $declaredVersion;
21
22
    public function getCustomRepositoryClassName() : ?string
23
    {
24
        return $this->customRepositoryClassName;
25
    }
26
27
    public function setCustomRepositoryClassName(?string $customRepositoryClassName) : void
28
    {
29
        $this->customRepositoryClassName = $customRepositoryClassName;
30
    }
31
32
    public function getDeclaredVersion() : ?Property
33
    {
34
        return $this->declaredVersion;
35
    }
36
37
    public function setDeclaredVersion(Property $property) : void
38
    {
39
        $this->declaredVersion = $property;
40
    }
41
42
    public function getVersion() : ?Property
43
    {
44
        /** @var MappedSuperClassMetadata|null $parent */
45
        $parent  = $this->parent;
46
        $version = $this->declaredVersion;
47
48
        if ($parent && ! $version) {
49
            $version = $parent->getVersion();
50
        }
51
52
        return $version;
53
    }
54
55
    public function isVersioned() : bool
56
    {
57
        return $this->getVersion() !== null;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function addDeclaredProperty(Property $property) : void
64
    {
65
        parent::addDeclaredProperty($property);
66
67
        if ($property instanceof VersionFieldMetadata) {
68
            $this->setDeclaredVersion($property);
69
        }
70
    }
71
}
72