<?php

namespace GriffinForms\Includes\Notifications;

use GriffinForms\Traits\Singleton;

class NotificationEventRegistry
{
    use Singleton;

    /** @var NotificationEventInterface[] Ordered list of registered events, keyed by event ID. */
    private array $events = [];

    public function register(NotificationEventInterface $event): void
    {
        $this->events[$event->getEventId()] = $event;
    }

    /** @return NotificationEventInterface[] */
    public function getAll(): array
    {
        return array_values($this->events);
    }

    public function get(string $event_id): ?NotificationEventInterface
    {
        return $this->events[$event_id] ?? null;
    }
}
