Test Setup Failed
Push — master ( b50703...9d91c5 )
by Dominik
06:16
created

PropertyAccessor::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Accessor;
6
7
final class PropertyAccessor implements AccessorInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $property;
13
14
    /**
15
     * @param string $property
16
     */
17
    public function __construct(string $property)
18
    {
19
        $this->property = $property;
20
    }
21
22
    /**
23
     * @param object $object
24
     * @param mixed  $value
25
     */
26 View Code Duplication
    public function setValue($object, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $reflectionProperty = new \ReflectionProperty(get_class($object), $this->property);
29
        $reflectionProperty->setAccessible(true);
30
31
        $reflectionProperty->setValue($object, $value);
32
    }
33
34
    /**
35
     * @param object $object
36
     *
37
     * @return mixed
38
     */
39 View Code Duplication
    public function getValue($object)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $reflectionProperty = new \ReflectionProperty(get_class($object), $this->property);
42
        $reflectionProperty->setAccessible(true);
43
44
        return $reflectionProperty->getValue($object);
45
    }
46
}
47