Passed
Push — master ( 85bdcb...9c9bde )
by Бабичев
01:36
created

Bind   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 45.71 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 16
loc 35
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperty() 8 8 1
A setProperty() 8 8 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
namespace Bavix\Tests;
4
5
abstract class Bind
6
{
7
8
    /**
9
     * @param object $object
10
     * @param string $attr
11
     *
12
     * @return mixed
13
     */
14 View Code Duplication
    public static function getProperty($object, $attr)
1 ignored issue
show
Duplication introduced by
This method 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...
15
    {
16 1
        $closure = \Closure::bind(function () use ($attr) {
17 1
            return $this->$attr;
18 1
        }, $object, \get_class($object));
19
20 1
        return $closure();
21
    }
22
23
    /**
24
     * @param object $object
25
     * @param string $attr
26
     * @param mixed  $value
27
     *
28
     * @return mixed
29
     */
30 View Code Duplication
    public static function setProperty($object, $attr, $value)
1 ignored issue
show
Duplication introduced by
This method 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...
31
    {
32 1
        $closure = \Closure::bind(function ($value) use ($attr) {
33 1
            $this->$attr = $value;
34 1
        }, $object, \get_class($object));
35
36
        return $closure($value);
37
    }
38
39
}
40