private $listener = []; public function attach(string $eventName, callable $callback): void { if (!isset($this->listener[$eventName])) { $this->listener[$eventName] = []; } $this->listener[$eventName][] = $callback; } public function trigger(string $eventName, EventInterface $event): void { if (isset($this->listener[$eventName])) { foreach ($this->listener[$eventName] as $listener) { $listener($event); if ($event->isPropagationStopped()){ break; } } } } }