Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ListingHistoryWriter
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 write
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Owners\Application\Services;
6
7use ImovelZapAi\Owners\Domain\Enums\ListingHistoryEvent;
8use ImovelZapAi\Owners\Infrastructure\Persistence\Eloquent\ListingHistoryModel;
9
10final class ListingHistoryWriter
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        ListingHistoryEvent $event,
19        ?string $opportunityId = null,
20        ?string $ownerId = null,
21        ?string $agreementId = null,
22        ?int $actorUserId = null,
23        ?array $before = null,
24        ?array $after = null,
25        ?string $message = null,
26    ): void {
27        ListingHistoryModel::query()->create([
28            'tenant_id' => $tenantId,
29            'listing_opportunity_id' => $opportunityId,
30            'owner_id' => $ownerId,
31            'listing_agreement_id' => $agreementId,
32            'actor_user_id' => $actorUserId,
33            'event' => $event,
34            'before' => $before,
35            'after' => $after,
36            'message' => $message,
37            'created_at' => now(),
38        ]);
39    }
40}