<?php

declare(strict_types=1);

namespace App\Framework\Http\Parser\Exception;

use App\Framework\Exception\FrameworkException;

/**
 * Exception thrown when parser security limits are exceeded
 */
final class ParserSecurityException extends FrameworkException
{
    public static function fileSizeExceeded(string $filename, int $actualSize, int $maxSize): self
    {
        return self::simple(
            "File size exceeded for '{$filename}': {$actualSize} bytes > {$maxSize} bytes maximum"
        );
    }

    public static function fileCountExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "File count exceeded: {$actualCount} files > {$maxCount} maximum"
        );
    }

    public static function totalUploadSizeExceeded(int $actualSize, int $maxSize): self
    {
        return self::simple(
            "Total upload size exceeded: {$actualSize} bytes > {$maxSize} bytes maximum"
        );
    }

    public static function fileExtensionBlocked(string $filename, string $extension): self
    {
        return self::simple(
            "File extension blocked for '{$filename}': '.{$extension}' is not allowed"
        );
    }

    public static function fileExtensionNotAllowed(string $filename, string $extension): self
    {
        return self::simple(
            "File extension not allowed for '{$filename}': '.{$extension}' is not in allowed list"
        );
    }

    public static function formDataSizeExceeded(int $actualSize, int $maxSize): self
    {
        return self::simple(
            "Form data size exceeded: {$actualSize} bytes > {$maxSize} bytes maximum"
        );
    }

    public static function fieldCountExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Field count exceeded: {$actualCount} fields > {$maxCount} maximum"
        );
    }

    public static function fieldNameTooLong(string $fieldName, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Field name too long '{$fieldName}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function fieldValueTooLong(string $fieldName, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Field value too long for '{$fieldName}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function maxPartsExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Maximum number of parts exceeded: {$actualCount} parts > {$maxCount} maximum"
        );
    }

    public static function queryStringSizeExceeded(int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Query string size exceeded: {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function queryParameterCountExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Query parameter count exceeded: {$actualCount} parameters > {$maxCount} maximum"
        );
    }

    public static function headerCountExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Header count exceeded: {$actualCount} headers > {$maxCount} maximum"
        );
    }

    public static function headerSizeExceeded(int $actualSize, int $maxSize): self
    {
        return self::simple(
            "Total header size exceeded: {$actualSize} bytes > {$maxSize} bytes maximum"
        );
    }

    public static function cookieCountExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Cookie count exceeded: {$actualCount} cookies > {$maxCount} maximum"
        );
    }

    public static function cookieNameTooLong(string $name, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Cookie name too long '{$name}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function cookieValueTooLong(string $name, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Cookie value too long for '{$name}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function multipartPartsExceeded(int $actualCount, int $maxCount): self
    {
        return self::simple(
            "Multipart parts exceeded: {$actualCount} parts > {$maxCount} maximum"
        );
    }

    public static function requestBodySizeExceeded(int $actualSize, int $maxSize): self
    {
        return self::simple(
            "Request body size exceeded: {$actualSize} bytes > {$maxSize} bytes maximum"
        );
    }

    public static function maliciousContentDetected(string $reason): self
    {
        return self::simple("Malicious content detected: {$reason}");
    }

    public static function mimeTypeMismatch(string $filename, string $expectedType, string $actualType): self
    {
        return self::simple(
            "MIME type mismatch for '{$filename}': expected '{$expectedType}', got '{$actualType}'"
        );
    }

    public static function headerNameTooLong(string $name, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Header name too long '{$name}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function headerValueTooLong(string $name, int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Header value too long for '{$name}': {$actualLength} characters > {$maxLength} maximum"
        );
    }

    public static function boundaryTooLong(int $actualLength, int $maxLength): self
    {
        return self::simple(
            "Multipart boundary too long: {$actualLength} characters > {$maxLength} maximum"
        );
    }
}
