<?php

declare(strict_types=1);

namespace App\Infrastructure\GeoIp;

final readonly class CountryInfo
{
    public function __construct(
        public string $ip,
        public ?string $countryCode,
        public ?Country $country = null
    ) {
    }

    public function hasCountry(): bool
    {
        return $this->countryCode !== null;
    }

    public function getGermanName(): ?string
    {
        return $this->country?->nameDe ?? $this->countryCode;
    }

    public function getEnglishName(): ?string
    {
        return $this->country?->nameEn ?? $this->countryCode;
    }

    public function getNativeName(): ?string
    {
        return $this->country?->nameNative ?? $this->countryCode;
    }
}
