<?php

declare(strict_types=1);

namespace App\Domain\Reporter;

use DateTimeImmutable;

/**
 * One ingest source. `trustWeight` (0.0–2.0) snapshots into each report
 * via `weight_at_report` so historical scoring isn't disturbed by later
 * trust changes.
 */
final class Reporter
{
    public function __construct(
        public readonly int $id,
        public readonly string $name,
        public readonly ?string $description,
        public readonly float $trustWeight,
        public readonly bool $isActive,
        public readonly bool $auditEnabled,
        public readonly ?int $createdByUserId,
        public readonly DateTimeImmutable $createdAt,
    ) {
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'description' => $this->description,
            'trust_weight' => $this->trustWeight,
            'is_active' => $this->isActive,
            'audit_enabled' => $this->auditEnabled,
            'created_by_user_id' => $this->createdByUserId,
            'created_at' => $this->createdAt->format('Y-m-d\TH:i:s\Z'),
        ];
    }
}
