Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
VisitLogWriter
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 write
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Visits\Application\Services;
6
7use ImovelZapAi\Visits\Domain\Enums\VisitLogEvent;
8use ImovelZapAi\Visits\Infrastructure\Persistence\Eloquent\VisitLogModel;
9
10final class VisitLogWriter
11{
12    /**
13     * @param  array<string, mixed>|null  $before
14     * @param  array<string, mixed>|null  $after
15     */
16    public function write(
17        string $tenantId,
18        string $visitId,
19        VisitLogEvent $event,
20        ?int $actorUserId = null,
21        ?array $before = null,
22        ?array $after = null,
23        ?string $message = null,
24    ): void {
25        VisitLogModel::query()->create([
26            'tenant_id' => $tenantId,
27            'visit_id' => $visitId,
28            'actor_user_id' => $actorUserId,
29            'event' => $event,
30            'before' => $before,
31            'after' => $after,
32            'message' => $message,
33            'created_at' => now(),
34        ]);
35    }
36}