<?php

declare(strict_types=1);

namespace App\Framework\Http\Batch;

/**
 * Configuration for batch processing
 */
final readonly class BatchConfig
{
    public function __construct(
        public int $maxOperations = 100,
        public int $maxConcurrentOperations = 10,
        public bool $allowContinueOnError = true,
        public array $allowedMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
        public int $timeoutSeconds = 30
    ) {
    }

    public static function default(): self
    {
        return new self();
    }

    public static function strict(): self
    {
        return new self(
            maxOperations: 50,
            maxConcurrentOperations: 5,
            allowContinueOnError: false,
            timeoutSeconds: 10
        );
    }

    public static function permissive(): self
    {
        return new self(
            maxOperations: 200,
            maxConcurrentOperations: 20,
            allowContinueOnError: true,
            timeoutSeconds: 60
        );
    }

    public function isMethodAllowed(string $method): bool
    {
        return in_array(strtoupper($method), $this->allowedMethods);
    }
}
