PublicAccessor::read()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Bdf\Serializer\PropertyAccessor;
4
5
/**
6
 * PublicAccessor
7
 *
8
 * Manage public property
9
 */
10
class PublicAccessor implements PropertyAccessorInterface
11
{
12
    /**
13
     * Property name
14
     *
15
     * @var string
16
     */
17
    private $property;
18
19
    /**
20
     * Constructor
21
     *
22
     * @param string $class
23
     * @param string $property
24
     */
25 72
    public function __construct(string $class, string $property)
26
    {
27 72
        $this->property = $property;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 26
    public function write($object, $value)
34
    {
35 26
        $object->{$this->property} = $value;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 48
    public function read($object)
42
    {
43 48
        return $object->{$this->property};
44
    }
45
}
46