Conditions | 8 |
Paths | 1 |
Total Lines | 27 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 8 |
Changes | 10 | ||
Bugs | 0 | Features | 3 |
1 | <?php |
||
26 | 3 | public function setToModel() |
|
27 | { |
||
28 | 3 | if ($this->fillModel === null) { |
|
29 | 3 | $this->fillModel = $this->createFillModelClosure(); |
|
30 | } |
||
31 | |||
32 | 3 | return $this->fillModel; |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return \Closure |
||
37 | */ |
||
38 | 4 | public function createGetFromModelClosure() |
|
39 | { |
||
40 | return function(PropRule $propRule, $dataKey){ |
||
41 | 2 | $getter = $propRule->getGet(); |
|
42 | 2 | $propVal = $propRule->getProp($dataKey); |
|
43 | 2 | $val = null; |
|
44 | |||
45 | 2 | if ($getter !== null) { |
|
46 | 2 | $method = is_array($getter) ? $getter[0] : $getter; |
|
47 | 2 | $args = is_array($getter) ? $getter[1] : []; |
|
48 | 2 | $val = call_user_func_array([$this, $method], $args); |
|
49 | 2 | } elseif ($propVal !== null && property_exists($this, $propVal)) { |
|
50 | 2 | $val = $this->{$propVal}; |
|
51 | } |
||
52 | |||
53 | 2 | return $val; |
|
70 |