Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ImportLogWriter | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| write | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Importing\Application\Services; |
| 6 | |
| 7 | use ImovelZapAi\Importing\Domain\Enums\ImportLogEvent; |
| 8 | use ImovelZapAi\Importing\Infrastructure\Persistence\Eloquent\ImportLogModel; |
| 9 | |
| 10 | final class ImportLogWriter |
| 11 | { |
| 12 | /** |
| 13 | * @param array<string, mixed>|null $diffBefore |
| 14 | * @param array<string, mixed>|null $diffAfter |
| 15 | * @param array<string, mixed> $context |
| 16 | */ |
| 17 | public function write( |
| 18 | string $tenantId, |
| 19 | string $importJobId, |
| 20 | ImportLogEvent $event, |
| 21 | ?string $propertyId = null, |
| 22 | ?string $externalId = null, |
| 23 | ?int $listingIndex = null, |
| 24 | ?string $result = null, |
| 25 | ?array $diffBefore = null, |
| 26 | ?array $diffAfter = null, |
| 27 | int $photosCount = 0, |
| 28 | ?int $durationMs = null, |
| 29 | ?string $message = null, |
| 30 | array $context = [], |
| 31 | ): void { |
| 32 | ImportLogModel::query()->create([ |
| 33 | 'tenant_id' => $tenantId, |
| 34 | 'import_job_id' => $importJobId, |
| 35 | 'property_id' => $propertyId, |
| 36 | 'external_id' => $externalId, |
| 37 | 'listing_index' => $listingIndex, |
| 38 | 'event' => $event, |
| 39 | 'result' => $result, |
| 40 | 'diff_before' => $diffBefore, |
| 41 | 'diff_after' => $diffAfter, |
| 42 | 'photos_count' => $photosCount, |
| 43 | 'duration_ms' => $durationMs, |
| 44 | 'message' => $message, |
| 45 | 'context' => $context, |
| 46 | 'created_at' => now(), |
| 47 | ]); |
| 48 | } |
| 49 | } |