Passed
Push — master ( da2126...3dbf39 )
by Sébastien
03:48
created

DelegateAccessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 62
ccs 7
cts 11
cp 0.6364
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A write() 0 3 1
A getReader() 0 3 1
A getWriter() 0 3 1
A read() 0 3 1
1
<?php
2
3
namespace Bdf\Serializer\PropertyAccessor;
4
5
/**
6
 * DelegateAccessor
7
 */
8
class DelegateAccessor implements PropertyAccessorInterface
9
{
10
    /**
11
     * The reader accessor
12
     *
13
     * @var PropertyAccessorInterface
14
     */
15
    private $reader;
16
17
    /**
18
     * The writer accessor
19
     *
20
     * @var PropertyAccessorInterface
21
     */
22
    private $writer;
23
24
    /**
25
     * DelegateAccessor constructor.
26
     *
27
     * @param PropertyAccessorInterface $reader
28
     * @param PropertyAccessorInterface $writer
29
     */
30 8
    public function __construct(PropertyAccessorInterface $reader, PropertyAccessorInterface $writer)
31
    {
32 8
        $this->reader = $reader;
33 8
        $this->writer = $writer;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function write($object, $value)
40
    {
41
        $this->writer->write($object, $value);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function read($object)
48
    {
49
        return $this->reader->read($object);
50
    }
51
52
    /**
53
     * Get the writer accessor
54
     *
55
     * @return PropertyAccessorInterface
56
     */
57 8
    public function getWriter(): PropertyAccessorInterface
58
    {
59 8
        return $this->writer;
60
    }
61
62
    /**
63
     * Get the reader accessor
64
     *
65
     * @return PropertyAccessorInterface
66
     */
67 8
    public function getReader(): PropertyAccessorInterface
68
    {
69 8
        return $this->reader;
70
    }
71
}
72