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
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
|
|||
34 | 1 | }, $object, \get_class($object)); |
|
35 | |||
36 | 1 | return $closure($value); |
|
37 | } |
||
38 | |||
39 | } |
||
40 |