<?php

namespace App\Enums;

enum ModerationSeverity: string
{
    case Low = 'low';
    case Medium = 'medium';
    case High = 'high';
    case Critical = 'critical';

    public function label(): string
    {
        return match ($this) {
            self::Low => 'Low',
            self::Medium => 'Medium',
            self::High => 'High',
            self::Critical => 'Critical',
        };
    }

    public function badgeClass(): string
    {
        return match ($this) {
            self::Low => 'badge-light',
            self::Medium => 'badge-warning',
            self::High => 'badge-danger',
            self::Critical => 'badge-dark text-white',
        };
    }

    public static function fromScore(int $score): self
    {
        $thresholds = app('config')->get('content_moderation.severity_thresholds', [
            'critical' => 90,
            'high'     => 60,
            'medium'   => 30,
        ]);

        if ($score >= $thresholds['critical']) {
            return self::Critical;
        }
        if ($score >= $thresholds['high']) {
            return self::High;
        }
        if ($score >= $thresholds['medium']) {
            return self::Medium;
        }

        return self::Low;
    }
}
