<?php

declare(strict_types=1);

namespace App\Domain\Enrichment;

use DateTimeImmutable;

/**
 * What an MMDB lookup returns for one IP. All three fields are nullable
 * because the upstream provider may have incomplete data, or because the
 * lookup found no matching record at all (in which case every field is
 * null and {@see isEmpty()} returns true — callers use that to skip
 * persisting "poison" rows).
 */
final class EnrichmentResult
{
    public function __construct(
        public readonly ?string $countryCode,
        public readonly ?int $asn,
        public readonly ?string $asOrg,
        public readonly DateTimeImmutable $enrichedAt,
    ) {
    }

    public function isEmpty(): bool
    {
        return $this->countryCode === null && $this->asn === null;
    }
}
