<?php

namespace WtbFirewall\Firewall;

// Prevent direct access.
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Definerer gyldige events som lagres i firewall log.
 * 
 */
enum EventType: int {

    case CONNECTION_BLOCKED = 1;    //Tilkobling stoppet av firewall.
    case WPLOGIN_AUTH_FAILED = 2;   //Mislykket wp-login autentisering.
    case XMLRPC_AUTH_FAILED = 3;    //Mislykket XMLRPC autentisering.
    case RATELIMIT_REQUESTS = 4;    //Rate limit, for mange requests.
    case RATELIMIT_404 = 5;         //Rate limit, for mange 404 feil.

    public function label(): string {
        return match ($this) {
            self::CONNECTION_BLOCKED => 'Blocked by firewall.',
            self::WPLOGIN_AUTH_FAILED => 'Wp-login authentication failed.',
            self::XMLRPC_AUTH_FAILED => 'XMLRPC authentication failed.',
            self::RATELIMIT_REQUESTS => 'Rate limiting, too many requests.',
            self::RATELIMIT_404 => 'Rate limiting, too many 404 errors.',
        };
    }

    public static function values(): array {
        return array_map(
                fn(self $case) => $case->value,
                self::cases()
        );
    }
}
