Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ProposalHistoryWriter | |
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\Proposals\Application\Services; |
| 6 | |
| 7 | use ImovelZapAi\Proposals\Domain\Enums\ProposalHistoryEvent; |
| 8 | use ImovelZapAi\Proposals\Infrastructure\Persistence\Eloquent\ProposalHistoryModel; |
| 9 | |
| 10 | final class ProposalHistoryWriter |
| 11 | { |
| 12 | /** @param array<string, mixed>|null $payload */ |
| 13 | public function write( |
| 14 | string $tenantId, |
| 15 | string $proposalId, |
| 16 | ProposalHistoryEvent $event, |
| 17 | string $actorType = 'system', |
| 18 | ?int $actorUserId = null, |
| 19 | ?array $payload = null, |
| 20 | ?string $message = null, |
| 21 | ): void { |
| 22 | ProposalHistoryModel::query()->create([ |
| 23 | 'tenant_id' => $tenantId, |
| 24 | 'proposal_id' => $proposalId, |
| 25 | 'event' => $event, |
| 26 | 'actor_type' => $actorType, |
| 27 | 'actor_user_id' => $actorUserId, |
| 28 | 'payload' => $payload, |
| 29 | 'message' => $message, |
| 30 | 'created_at' => now(), |
| 31 | ]); |
| 32 | } |
| 33 | } |