Completed
Push — master ( fef923...c0df34 )
by Rafael
03:03
created

AccessorWriter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A isWritable() 0 4 1
A setValue() 0 4 1
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Writer;
11
12
use Symfony\Component\PropertyAccess\PropertyAccessor;
13
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
14
15
/**
16
 * Class AccessorWriter
17
 */
18
class AccessorWriter implements PropertyWriterInterface
19
{
20
21
    /**
22
     * @var PropertyAccessor
23
     */
24
    protected $accessor;
25
26
    /**
27
     * AccessorWriter constructor.
28
     *
29
     * @param PropertyAccessorBuilder|null $builder
30
     */
31
    public function __construct(PropertyAccessorBuilder $builder = null)
32
    {
33
        if (!$builder) {
34
            $builder = new PropertyAccessorBuilder();
35
        }
36
37
        $this->accessor = $builder->getPropertyAccessor();
38
    }
39
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function isWritable($object, $propertyPath)
45
    {
46
        return $this->accessor->isWritable($object, $propertyPath);
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function setValue(&$object, $propertyPath, $value)
53
    {
54
        $this->accessor->setValue($object, $propertyPath, $value);
55
    }
56
}