<?php

declare(strict_types=1);

namespace PhpWA\Protocol\Binary;

use InvalidArgumentException;

final class BinaryCodecOptions
{
    /** @var int */ public $maxFrameBytes;
    /** @var int */ public $maxInflatedBytes;
    /** @var int */ public $maxDepth;
    /** @var int */ public $maxNodes;
    /** @var int */ public $maxAttributesPerNode;
    /** @var int */ public $maxChildrenPerNode;

    public function __construct(
        int $maxFrameBytes = 33554432,
        int $maxInflatedBytes = 67108864,
        int $maxDepth = 64,
        int $maxNodes = 20000,
        int $maxAttributesPerNode = 1024,
        int $maxChildrenPerNode = 10000
    ) {
        foreach (func_get_args() as $value) {
            if (!is_int($value) || $value <= 0) {
                throw new InvalidArgumentException('Binary codec limits must be positive integers.');
            }
        }
        $this->maxFrameBytes = $maxFrameBytes;
        $this->maxInflatedBytes = $maxInflatedBytes;
        $this->maxDepth = $maxDepth;
        $this->maxNodes = $maxNodes;
        $this->maxAttributesPerNode = $maxAttributesPerNode;
        $this->maxChildrenPerNode = $maxChildrenPerNode;
    }
}
