private function handleCommand($aggregate, $command) { $method = $this->aggregates->handleMethod($command); if (!method_exists($aggregate, $method)) { throw new \Exception("Missing method " . get_class($aggregate) . "::{$method}()"); } return $aggregate->{$method}($command); }
/** * @param mixed $command * @return string */ public function handleMethod($command) { return $this->first->handleMethod($command) ?: $this->second->handleMethod($command); }