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