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