getComment()->getObjectType() !== 'files') { // this is a 'files'-specific Handler return; } $eventType = $event->getEvent(); if ($eventType === CommentsEvent::EVENT_ADD ) { $this->notificationHandler($event); $this->activityHandler($event); return; } $applicableEvents = [ CommentsEvent::EVENT_PRE_UPDATE, CommentsEvent::EVENT_UPDATE, CommentsEvent::EVENT_DELETE, ]; if (in_array($eventType, $applicableEvents)) { $this->notificationHandler($event); return; } } private function activityHandler(CommentsEvent $event): void { $this->activityListener->commentEvent($event); } private function notificationHandler(CommentsEvent $event): void { $this->notificationListener->evaluate($event); } }