<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Consumer\Batch;

final class QueueConsumerBatchOptions
{
    public function __construct(
        private readonly int $limit = 10,
        private readonly bool $stopOnFailure = false,
        private readonly bool $recordEmpty = false
    ) {}

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

    public static function limit(int $limit): self
    {
        return new self($limit);
    }

    public function limitValue(): int { return max(1, $this->limit); }
    public function stopOnFailure(): bool { return $this->stopOnFailure; }
    public function recordEmpty(): bool { return $this->recordEmpty; }

    public function toArray(): array
    {
        return [
            'limit' => $this->limitValue(),
            'stopOnFailure' => $this->stopOnFailure,
            'recordEmpty' => $this->recordEmpty,
        ];
    }
}
