<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Registry;

final class ListenerRegistrySnapshot
{
    public function __construct(
        private readonly array $events,
        private readonly array $records,
        private readonly int $listenerCount
    ) {}

    public function events(): array { return $this->events; }
    public function records(): array { return $this->records; }
    public function listenerCount(): int { return $this->listenerCount; }

    public function toArray(): array
    {
        return [
            'events' => $this->events,
            'listenerCount' => $this->listenerCount,
            'records' => array_map(
                static fn (ListenerRecord $record): array => $record->toArray(),
                $this->records
            ),
        ];
    }
}
