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

Bind::getProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
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