Passed
Pull Request — master (#9)
by Vincent
05:08 queued 01:37
created

DelegateAccessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
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