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

AccessorReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

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 37
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 2
A isReadable() 4 4 1
A getValue() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}