<?php

declare(strict_types=1);

namespace App\Framework\DDoS\Response\ValueObjects;

/**
 * DDoS Response Types - Categories of mitigation responses
 */
enum ResponseType: string
{
    case ALLOW = 'allow';
    case BLOCK = 'block';
    case RATE_LIMITED = 'rate_limited';
    case CHALLENGE = 'challenge';
    case TAR_PIT = 'tar_pit';

    public function getDescription(): string
    {
        return match ($this) {
            self::ALLOW => 'Request allowed to proceed normally',
            self::BLOCK => 'Request blocked due to threat detection',
            self::RATE_LIMITED => 'Request rate limited due to excessive frequency',
            self::CHALLENGE => 'Request requires user challenge completion',
            self::TAR_PIT => 'Request delayed to waste attacker resources'
        };
    }

    public function isBlocking(): bool
    {
        return match ($this) {
            self::BLOCK, self::RATE_LIMITED => true,
            default => false
        };
    }

    public function allowsRequest(): bool
    {
        return match ($this) {
            self::ALLOW, self::CHALLENGE, self::TAR_PIT => true,
            default => false
        };
    }

    public function requiresSpecialHandling(): bool
    {
        return match ($this) {
            self::CHALLENGE, self::TAR_PIT => true,
            default => false
        };
    }
}
