Bind::setProperty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
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
    public static function getProperty($object, $attr)
15
    {
16 1
        $closure = \Closure::bind(function () use ($attr) {
17 1
            return $this->$attr;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
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
    public static function setProperty($object, $attr, $value)
31
    {
32 1
        $closure = \Closure::bind(function ($value) use ($attr) {
33 1
            $this->$attr = $value;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
34 1
        }, $object, \get_class($object));
35
36 1
        return $closure($value);
37
    }
38
39
}
40