Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public static function map(ModelInterface $model, $dto) |
||
20 | { |
||
21 | $accessor = PropertyAccess::createPropertyAccessor(); |
||
22 | |||
23 | $mapping = array_filter($model->getMapping(), function ($value) { |
||
24 | return !is_null($value); |
||
25 | }); |
||
26 | |||
27 | foreach ($mapping as $source => $dest) { |
||
28 | try { |
||
29 | $accessor->setValue( |
||
30 | $model, |
||
31 | $dest, |
||
32 | $accessor->getValue($dto, $source) |
||
33 | ); |
||
34 | } catch (\Exception $e) { |
||
35 | continue; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | return $model; |
||
|
|||
40 | } |
||
41 | } |
||
42 |