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

MappedSuperClassMetadata   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 59
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setCustomRepositoryClassName() 0 3 1
A getVersion() 0 11 3
A isVersioned() 0 3 1
A setDeclaredVersion() 0 3 1
A getCustomRepositoryClassName() 0 3 1
A getDeclaredVersion() 0 3 1
A addDeclaredProperty() 0 6 2
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