PublicAccessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 34
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 3 1
A __construct() 0 3 1
A read() 0 3 1
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