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