<?php

declare(strict_types=1);

namespace App\Infrastructure\Api\RapidMail;

final readonly class RecipientId
{
    public function __construct(
        public int $value,
    ) {
        if ($value <= 0) {
            throw new \InvalidArgumentException('RecipientId must be positive');
        }
    }

    public static function fromInt(int $id): RecipientId
    {
        return new RecipientId($id);
    }

    public function equals(RecipientId $other): bool
    {
        return $this->value === $other->value;
    }

    public function __toString(): string
    {
        return (string) $this->value;
    }
}
