<?php

declare(strict_types=1);

namespace App\Framework\Notification\ValueObjects;

/**
 * Notification delivery and read status
 */
enum NotificationStatus: string
{
    case PENDING = 'pending';
    case SENT = 'sent';
    case DELIVERED = 'delivered';
    case FAILED = 'failed';
    case READ = 'read';
    case ARCHIVED = 'archived';

    public function isFinal(): bool
    {
        return match ($this) {
            self::DELIVERED, self::FAILED, self::READ, self::ARCHIVED => true,
            self::PENDING, self::SENT => false,
        };
    }

    public function canRetry(): bool
    {
        return match ($this) {
            self::FAILED => true,
            self::PENDING, self::SENT, self::DELIVERED, self::READ, self::ARCHIVED => false,
        };
    }

    public function isSuccessful(): bool
    {
        return match ($this) {
            self::SENT, self::DELIVERED, self::READ => true,
            self::PENDING, self::FAILED, self::ARCHIVED => false,
        };
    }
}
