Code Duplication    Length = 37-39 lines in 2 locations

src/Reader/AccessorReader.php 1 location

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

src/Writer/AccessorWriter.php 1 location

@@ 18-56 (lines=39) @@
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
}