Completed
Push — master ( 366fbf...5f1478 )
by Rafael
02:45
created

AccessorReader::isReadable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
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\Reader;
11
12
use Symfony\Component\PropertyAccess\PropertyAccessor;
13
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
14
15 View Code Duplication
class AccessorReader implements PropertyReaderInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}