private function applyEvents($object, array $events) { foreach ($events as $event) { $method = $this->aggregates->applyMethod($event); if (method_exists($object, $method)) { $object->{$method}($event); } } }
/** * @param mixed $event * @return string */ public function applyMethod($event) { return $this->first->applyMethod($event) ?: $this->second->applyMethod($event); }