<?php

namespace App\ValueObjects\Communications;

use App\Enum\Contact\MessageChannel;
use App\Enum\Contact\RecipientValidity;

class RecipientSnapshot
{
    public function __construct(
        public readonly MessageChannel $channel,
        public readonly ?string $name,
        public readonly ?string $email,
        public readonly ?string $phone,
        public readonly RecipientValidity $validity,
        public readonly ?string $reason = null,
    ) {}

    public function canSend(): bool
    {
        return $this->validity->canSend();
    }

    public function value(): ?string
    {
        return $this->channel === MessageChannel::EMAIL ? $this->email : $this->phone;
    }
}
