<?php

declare(strict_types=1);

namespace App\Framework\ErrorBoundaries\Metrics;

/**
 * Health status enumeration for error boundaries
 */
enum BoundaryHealthStatus: string
{
    case HEALTHY = 'healthy';
    case WARNING = 'warning';
    case CRITICAL = 'critical';
    case UNKNOWN = 'unknown';

    /**
     * Get human-readable description
     */
    public function getDescription(): string
    {
        return match ($this) {
            self::HEALTHY => 'Boundary is operating normally',
            self::WARNING => 'Boundary has elevated error rates but is functional',
            self::CRITICAL => 'Boundary has high error rates and may be failing',
            self::UNKNOWN => 'Boundary health status cannot be determined',
        };
    }

    /**
     * Get severity level for alerting
     */
    public function getSeverity(): int
    {
        return match ($this) {
            self::HEALTHY => 0,
            self::WARNING => 1,
            self::CRITICAL => 2,
            self::UNKNOWN => 1,
        };
    }

    /**
     * Get color representation for UI
     */
    public function getColor(): string
    {
        return match ($this) {
            self::HEALTHY => 'green',
            self::WARNING => 'yellow',
            self::CRITICAL => 'red',
            self::UNKNOWN => 'gray',
        };
    }

    /**
     * Get emoji representation
     */
    public function getEmoji(): string
    {
        return match ($this) {
            self::HEALTHY => '✅',
            self::WARNING => '⚠️',
            self::CRITICAL => '🚨',
            self::UNKNOWN => '❓',
        };
    }

    /**
     * Check if status requires immediate attention
     */
    public function requiresAttention(): bool
    {
        return $this === self::CRITICAL;
    }

    /**
     * Check if status should trigger alerts
     */
    public function shouldAlert(): bool
    {
        return $this === self::WARNING || $this === self::CRITICAL;
    }
}
