Code Duplication    Length = 37-39 lines in 2 locations

src/Reader/AccessorReader.php 1 location

@@ 16-52 (lines=37) @@
13
use Symfony\Component\PropertyAccess\PropertyAccessor;
14
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
15
16
class AccessorReader implements PropertyReaderInterface
17
{
18
    /**
19
     * @var PropertyAccessor
20
     */
21
    protected $accessor;
22
23
    /**
24
     * AccessorWriter constructor.
25
     *
26
     * @param PropertyAccessorBuilder|null $builder
27
     */
28
    public function __construct(PropertyAccessorBuilder $builder = null)
29
    {
30
        if (!$builder) {
31
            $builder = new PropertyAccessorBuilder();
32
        }
33
34
        $this->accessor = $builder->getPropertyAccessor();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function isReadable($object, $propertyPath)
41
    {
42
        return $this->accessor->isReadable($object, $propertyPath);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getValue($object, $propertyPath)
49
    {
50
        return $this->accessor->getValue($object, $propertyPath);
51
    }
52
}
53

src/Writer/AccessorWriter.php 1 location

@@ 19-57 (lines=39) @@
16
/**
17
 * Class AccessorWriter.
18
 */
19
class AccessorWriter implements PropertyWriterInterface
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
     * {@inheritdoc}
42
     */
43
    public function isWritable($object, $propertyPath)
44
    {
45
        return $this->accessor->isWritable($object, $propertyPath);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function setValue(&$object, $propertyPath, $value)
52
    {
53
        $this->accessor->setValue($object, $propertyPath, $value);
54
    }
55
}
56