Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 5 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
18 | 8 | public function mapModelAttributes(?Model $model = null): void |
|
19 | { |
||
20 | 8 | if (! is_null($model)) { |
|
21 | 8 | $toIgnore = config('model-mapper.ignore_attributes'); |
|
22 | |||
23 | 8 | $ignores = is_array($toIgnore) |
|
24 | 7 | ? $toIgnore |
|
25 | 1 | : ['id', 'password']; |
|
26 | |||
27 | 8 | collect($model->getAttributes()) |
|
28 | 8 | ->except($ignores) |
|
29 | 8 | ->each(function ($value, $property) use ($model) { |
|
30 | 8 | if (property_exists($this, $property)) { |
|
31 | 8 | rescue( |
|
32 | 8 | fn () => $this->{$property} = $model->{$property}, |
|
33 | 8 | fn () => null, |
|
34 | 8 | config('model-mapper.log') ?? false |
|
35 | ); |
||
41 |