<?php
declare(strict_types=1);

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

final class QueueConsumerSnapshotReconciler
{
    public function reconcile(array $snapshot): array
    {
        return [
            'statistics' => (array) ($snapshot['statistics'] ?? []),
            'queue' => (array) ($snapshot['queue'] ?? []),
            'pool' => (array) ($snapshot['pool'] ?? []),
            'createdAt' => (string) ($snapshot['createdAt'] ?? date('c')),
        ];
    }

    public function valid(array $snapshot): bool
    {
        return isset($snapshot['statistics'], $snapshot['queue'], $snapshot['pool']);
    }
}
