<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Consumer;

use PpPhp\Core\Platform\Event\Consumer\Hydration\QueueConsumerCrossProcessHydrator;

final class QueueConsumerConsoleStateHydrator
{
    private QueueConsumerCrossProcessHydrator $hydrator;

    public function __construct(private readonly QueueConsumerManager $manager)
    {
        $this->hydrator = new QueueConsumerCrossProcessHydrator($manager);
    }

    public function statistics(): array
    {
        return $this->hydrator->hydrate()['statistics'];
    }

    public function snapshot(): array
    {
        return $this->hydrator->hydrate()['snapshot'];
    }

    public function batchStatistics(): array
    {
        return $this->hydrator->hydrate()['batchStatistics'];
    }

    public function validation(): array
    {
        return $this->hydrator->hydrate()['validation'];
    }

    public function persisted(): bool
    {
        return (bool) ($this->hydrator->hydrate()['persisted'] ?? false);
    }

    public function hydratedState(): array
    {
        return $this->hydrator->hydrate();
    }
}
