Failed Conditions
Push — master ( becf73...b9880b )
by Guilherme
09:53
created

FieldMetadata::isVersioned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Mapping;
6
7
use Doctrine\ORM\Reflection\ReflectionService;
8
use ReflectionProperty;
9
10
class FieldMetadata extends LocalColumnMetadata implements Property
11
{
12
    /** @var ComponentMetadata */
13
    protected $declaringClass;
14
15
    /** @var ReflectionProperty */
16
    protected $reflection;
17
18
    /** @var string */
19
    protected $name;
20
21
    /** @var bool */
22
    protected $versioned = false;
23
24 413
    public function __construct(string $name/*, string $columnName, Type $type*/)
25
    {
26
//        @todo Leverage this implementation instead of default, simple constructor
27
//        parent::__construct($columnName, $type);
28 413
        $this->name = $name;
29 413
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 807
    public function getDeclaringClass() : ComponentMetadata
35
    {
36 807
        return $this->declaringClass;
37
    }
38
39 412
    public function setDeclaringClass(ComponentMetadata $declaringClass) : void
40
    {
41 412
        $this->declaringClass = $declaringClass;
42 412
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 897
    public function getName() : string
48
    {
49 897
        return $this->name;
50
    }
51
52 1265
    public function isVersioned() : bool
53
    {
54 1265
        return $this->versioned;
55
    }
56
57 400
    public function setVersioned(bool $versioned) : void
58
    {
59 400
        $this->versioned = $versioned;
60 400
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1062
    public function setValue($object, $value) : void
66
    {
67 1062
        $this->reflection->setValue($object, $value);
68 1062
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73 1073
    public function getValue($object)
74
    {
75 1073
        return $this->reflection->getValue($object);
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function isAssociation() : bool
82
    {
83
        return false;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function isField() : bool
90
    {
91
        return true;
92
    }
93
94
    /**
95
     * {@inheritdoc}
96
     */
97 1993
    public function setReflectionProperty(ReflectionProperty $reflectionProperty) : void
98
    {
99 1993
        $this->reflection = $reflectionProperty;
100 1993
    }
101
102
    /**
103
     * {@inheritdoc}
104
     */
105 1632
    public function wakeupReflection(ReflectionService $reflectionService) : void
106
    {
107 1632
        $this->setReflectionProperty(
108 1632
            $reflectionService->getAccessibleProperty($this->declaringClass->getClassName(), $this->name)
0 ignored issues
show
Bug introduced by
It seems like $reflectionService->getA...assName(), $this->name) can also be of type null; however, parameter $reflectionProperty of Doctrine\ORM\Mapping\Fie...setReflectionProperty() does only seem to accept ReflectionProperty, maybe add an additional type check? ( Ignorable by Annotation )

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

108
            /** @scrutinizer ignore-type */ $reflectionService->getAccessibleProperty($this->declaringClass->getClassName(), $this->name)
Loading history...
109
        );
110 1632
    }
111
}
112