Conditions | 3 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public function populate(string $class, array $data, $relations = false) |
||
33 | { |
||
34 | $itemMap = ArrayHelper::getValue($this->map(), "$class.item", []); |
||
35 | |||
36 | $model = new $class(); |
||
37 | foreach ($itemMap as $to => $from) { |
||
38 | $model->$to = ArrayHelper::getValue($data, $from); |
||
39 | } |
||
40 | |||
41 | if ($relations) { |
||
42 | $this->populateRelations($model, $data); |
||
43 | } |
||
44 | |||
45 | return $model; |
||
46 | } |
||
62 | } |