Failed Conditions
Push — master ( 906c14...99b7d1 )
by Guilherme
09:01
created

MappedSuperClassMetadata::addProperty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
class MappedSuperClassMetadata extends ComponentMetadata
8
{
9
    /** @var string|null */
10
    protected $customRepositoryClassName;
11
12
    /** @var Property|null */
13
    protected $declaredVersion;
14
15
    public function getCustomRepositoryClassName() : ?string
16
    {
17
        return $this->customRepositoryClassName;
18
    }
19
20
    public function setCustomRepositoryClassName(?string $customRepositoryClassName) : void
21
    {
22
        $this->customRepositoryClassName = $customRepositoryClassName;
23
    }
24
25
    public function getDeclaredVersion() : ?Property
26
    {
27
        return $this->declaredVersion;
28
    }
29
30
    public function setDeclaredVersion(Property $property) : void
31
    {
32
        $this->declaredVersion = $property;
33
    }
34
35
    public function getVersion() : ?Property
36
    {
37
        /** @var MappedSuperClassMetadata|null $parent */
38
        $parent  = $this->parent;
39
        $version = $this->declaredVersion;
40
41
        if ($parent && ! $version) {
42
            $version = $parent->getVersion();
43
        }
44
45
        return $version;
46
    }
47
48
    public function isVersioned() : bool
49
    {
50
        return $this->getVersion() !== null;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function addProperty(Property $property) : void
57
    {
58
        parent::addProperty($property);
59
60
        if ($property->isVersioned()) {
0 ignored issues
show
Bug introduced by
The method isVersioned() does not exist on Doctrine\ORM\Mapping\Property. It seems like you code against a sub-type of Doctrine\ORM\Mapping\Property such as Doctrine\ORM\Mapping\FieldMetadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
        if ($property->/** @scrutinizer ignore-call */ isVersioned()) {
Loading history...
61
            $this->setDeclaredVersion($property);
62
        }
63
    }
64
}
65