/** * @param CommandMessage $message * @return CommandHandler * @throws NoCommandHandlerFound */ public function locate(CommandMessage $message) { $name = $message->name(); if (!array_key_exists($name, $this->registry)) { throw NoCommandHandlerFound::forMessage($message); } return $this->registry[$name]; }
/** * @param CommandMessage $message * @return CommandMessage */ public function proceed(CommandMessage $message) { $this->processed = $message->name(); return $message; }
/** * @param CommandMessage $message * @return static */ public static function forMessage(CommandMessage $message) { return new static(sprintf('No handle method for command %s.', $message->name())); }