<?php
declare(strict_types=1);

namespace App\Application\Security\ValueObjects;

use App\Application\Security\SecurityEventType;

enum OWASPLogLevel: string
{
    case DEBUG = 'DEBUG';
    case INFO = 'INFO';
    case WARN = 'WARN';
    case ERROR = 'ERROR';
    case FATAL = 'FATAL';

    public static function fromSecurityEventType(SecurityEventType $type): self
    {
        return match ($type) {
            SecurityEventType::LOGIN_SUCCESS,
            SecurityEventType::LOGOUT,
            SecurityEventType::PASSWORD_CHANGE => self::INFO,

            SecurityEventType::LOGIN_FAILED,
            SecurityEventType::ACCESS_DENIED,
            SecurityEventType::SESSION_TIMEOUT => self::WARN,

            SecurityEventType::INJECTION_ATTEMPT,
            SecurityEventType::MALWARE_DETECTED,
            SecurityEventType::ACCOUNT_LOCKED,
            SecurityEventType::FILE_UPLOAD => self::ERROR,

            SecurityEventType::PRIVILEGE_ESCALATION,
            SecurityEventType::SESSION_HIJACK,
            SecurityEventType::AUDIT_FAILURE => self::FATAL,

            default => self::INFO
        };
    }
}
