<?php

declare(strict_types=1);

namespace PhpWA\Protocol\Binary;

use InvalidArgumentException;

final class BinaryCodecOptions
{
      public $maxFrameBytes;
      public $maxInflatedBytes;
      public $maxDepth;
      public $maxNodes;
      public $maxAttributesPerNode;
      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;
    }
}
