Conditions | 5 |
Paths | 6 |
Total Lines | 29 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5.0113 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 16 | public function populate( |
|
19 | FormModel $model, |
||
20 | mixed $data, |
||
21 | array $map = [], |
||
22 | bool $strict = false, |
||
23 | ?string $scope = null |
||
24 | ): bool { |
||
25 | 16 | if (!is_array($data)) { |
|
26 | 2 | return false; |
|
27 | } |
||
28 | |||
29 | 14 | $scope ??= $model->getFormName(); |
|
30 | 14 | if ($scope === '') { |
|
31 | 3 | $hydrateData = $data; |
|
32 | } else { |
||
33 | 12 | if (!isset($data[$scope])) { |
|
34 | 2 | return false; |
|
35 | } |
||
36 | /** @var mixed $hydrateData */ |
||
37 | 10 | $hydrateData = $data[$scope]; |
|
38 | } |
||
39 | |||
40 | 13 | if (!is_array($hydrateData)) { |
|
41 | return false; |
||
42 | } |
||
43 | |||
44 | 13 | $this->hydrator->populate($model, $hydrateData, $map, $strict); |
|
45 | |||
46 | 13 | return true; |
|
47 | } |
||
49 |