Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
21 | 7 | protected function fromArray(array $data) |
|
22 | { |
||
23 | 7 | foreach($data as $key => $value) { |
|
24 | 6 | if (!property_exists($this, $key)) { |
|
25 | 1 | throw new InvalidArgumentException("Invalid search result item property: {$key}"); |
|
26 | } |
||
27 | |||
28 | 5 | $validatorMethod = 'validate' . ucfirst($key); |
|
29 | 5 | if (method_exists($this, $validatorMethod)) { |
|
30 | 5 | $this->{$validatorMethod}($value); |
|
31 | } |
||
32 | |||
33 | 4 | $this->{$key} = $value; |
|
34 | } |
||
35 | 5 | } |
|
36 | |||
65 |