<?php

declare(strict_types=1);

namespace App\Framework\Http\Services;

enum IpRiskLevel: string
{
    case SAFE = 'safe';
    case LOW = 'low';
    case MEDIUM = 'medium';
    case HIGH = 'high';
    case CRITICAL = 'critical';

    public function getScore(): int
    {
        return match ($this) {
            self::SAFE => 0,
            self::LOW => 1,
            self::MEDIUM => 2,
            self::HIGH => 3,
            self::CRITICAL => 4,
        };
    }

    public function getName(): string
    {
        return match ($this) {
            self::SAFE => 'Safe',
            self::LOW => 'Low Risk',
            self::MEDIUM => 'Medium Risk',
            self::HIGH => 'High Risk',
            self::CRITICAL => 'Critical Risk',
        };
    }

    public function shouldBlock(): bool
    {
        return $this === self::CRITICAL;
    }

    public function shouldLimit(): bool
    {
        return $this->getScore() >= 2;
    }
}
