<?php

declare(strict_types=1);

namespace App\Framework\Health\ValueObjects;

/**
 * Enum for health message types
 * Provides type safety for different kinds of health messages
 */
enum HealthMessageType: string
{
    case SUCCESS = 'success';
    case WARNING = 'warning';
    case FAILURE = 'failure';
    case TIMEOUT = 'timeout';
    case DEGRADED = 'degraded';
    case PLAIN = 'plain';

    public function getEmoji(): string
    {
        return match ($this) {
            self::SUCCESS => '✓',
            self::WARNING => '⚠',
            self::FAILURE => '✗',
            self::TIMEOUT => '⏱',
            self::DEGRADED => '⚡',
            self::PLAIN => ''
        };
    }

    public function getColorClass(): string
    {
        return match ($this) {
            self::SUCCESS => 'text-green-600',
            self::WARNING => 'text-yellow-600',
            self::FAILURE => 'text-red-600',
            self::TIMEOUT => 'text-orange-600',
            self::DEGRADED => 'text-blue-600',
            self::PLAIN => 'text-gray-600'
        };
    }

    public function getSeverityLevel(): int
    {
        return match ($this) {
            self::SUCCESS => 0,
            self::DEGRADED => 1,
            self::WARNING => 2,
            self::TIMEOUT => 3,
            self::FAILURE => 4,
            self::PLAIN => 0
        };
    }

    public function isError(): bool
    {
        return in_array($this, [self::FAILURE, self::TIMEOUT]);
    }

    public function isWarningLevel(): bool
    {
        return in_array($this, [self::WARNING, self::DEGRADED]);
    }

    public function isSuccess(): bool
    {
        return $this === self::SUCCESS;
    }
}
