<?php

declare(strict_types=1);

namespace PpPhp\Core\Diagnostics;

final class Severity
{
    public const INFO = 'info';
    public const WARNING = 'warning';
    public const ERROR = 'error';
    public const CRITICAL = 'critical';

    public static function weight(string $severity): int
    {
        return match ($severity) {
            self::CRITICAL => 20,
            self::ERROR => 10,
            self::WARNING => 1,
            default => 0,
        };
    }

    public static function isProblem(string $severity): bool
    {
        return in_array($severity, [self::WARNING, self::ERROR, self::CRITICAL], true);
    }
}
