Completed
Push — master ( 812d68...15b189 )
by Pieter
17s queued 10s
created

ReflectionPropertyGetter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A toType() 0 3 1
A __construct() 0 3 1
A getName() 0 3 1
A getPriority() 0 3 1
A getValue() 0 3 1
1
<?php
2
3
4
namespace W2w\Lib\ApieObjectAccessNormalizer\Getters;
5
6
use ReflectionProperty;
7
use Symfony\Component\PropertyInfo\Type;
8
use W2w\Lib\ApieObjectAccessNormalizer\TypeUtils;
9
10
class ReflectionPropertyGetter implements GetterInterface
11
{
12
    /**
13
     * @var ReflectionProperty
14
     */
15
    private $property;
16
17
    public function __construct(ReflectionProperty $property)
18
    {
19
        $this->property = $property;
20
    }
21
22
    public function getName(): string
23
    {
24
        return $this->property->getName();
25
    }
26
27
    public function getValue($object)
28
    {
29
        return $this->property->getValue($object);
30
    }
31
32
    public function getPriority(): int
33
    {
34
        return 0;
35
    }
36
37
    public function toType(): ?Type
38
    {
39
        return TypeUtils::convertPropertyToType($this->property);
40
    }
41
}
42