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

ReflectionMethodSetter   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 getName() 0 3 1
A __construct() 0 3 1
A toType() 0 3 1
A getPriority() 0 3 1
A setValue() 0 3 1
1
<?php
2
3
namespace W2w\Lib\ApieObjectAccessNormalizer\Setters;
4
5
use ReflectionMethod;
6
use Symfony\Component\PropertyInfo\Type;
7
use W2w\Lib\ApieObjectAccessNormalizer\TypeUtils;
8
9
class ReflectionMethodSetter implements SetterInterface
10
{
11
    /**
12
     * @var ReflectionMethod
13
     */
14
    private $method;
15
16
    public function __construct(ReflectionMethod $method)
17
    {
18
        $this->method = $method;
19
    }
20
21
    public function setValue($object, $newValue)
22
    {
23
        return $this->method->invoke($object, $newValue);
24
    }
25
26
    public function getName(): string
27
    {
28
        return $this->method->getName();
29
    }
30
31
    public function getPriority(): int
32
    {
33
        return 3;
34
    }
35
36
    public function toType(): ?Type
37
    {
38
        return TypeUtils::convertMethodToType($this->method);
39
    }
40
}
41