Reporter.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Domain\Reporter;
  4. use DateTimeImmutable;
  5. /**
  6. * One ingest source. `trustWeight` (0.0–2.0) snapshots into each report
  7. * via `weight_at_report` so historical scoring isn't disturbed by later
  8. * trust changes.
  9. */
  10. final class Reporter
  11. {
  12. public function __construct(
  13. public readonly int $id,
  14. public readonly string $name,
  15. public readonly ?string $description,
  16. public readonly float $trustWeight,
  17. public readonly bool $isActive,
  18. public readonly ?int $createdByUserId,
  19. public readonly DateTimeImmutable $createdAt,
  20. ) {
  21. }
  22. /**
  23. * @return array<string, mixed>
  24. */
  25. public function toArray(): array
  26. {
  27. return [
  28. 'id' => $this->id,
  29. 'name' => $this->name,
  30. 'description' => $this->description,
  31. 'trust_weight' => $this->trustWeight,
  32. 'is_active' => $this->isActive,
  33. 'created_by_user_id' => $this->createdByUserId,
  34. 'created_at' => $this->createdAt->format('Y-m-d\TH:i:s\Z'),
  35. ];
  36. }
  37. }