Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| VisitSnapshotter | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| snapshot | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Visits\Application\Services; |
| 6 | |
| 7 | use ImovelZapAi\Visits\Infrastructure\Persistence\Eloquent\VisitModel; |
| 8 | |
| 9 | final class VisitSnapshotter |
| 10 | { |
| 11 | /** |
| 12 | * @return array<string, mixed> |
| 13 | */ |
| 14 | public function snapshot(VisitModel $visit): array |
| 15 | { |
| 16 | return [ |
| 17 | 'status' => $visit->status instanceof \BackedEnum ? $visit->status->value : (string) $visit->status, |
| 18 | 'responsible_user_id' => $visit->responsible_user_id, |
| 19 | 'property_id' => $visit->property_id, |
| 20 | 'scheduled_start' => $visit->scheduled_start?->toIso8601String(), |
| 21 | 'scheduled_end' => $visit->scheduled_end?->toIso8601String(), |
| 22 | 'outcome' => $visit->outcome instanceof \BackedEnum ? $visit->outcome->value : $visit->outcome, |
| 23 | 'check_in_at' => $visit->check_in_at?->toIso8601String(), |
| 24 | 'check_out_at' => $visit->check_out_at?->toIso8601String(), |
| 25 | ]; |
| 26 | } |
| 27 | } |