container = $container; $this->commandToServiceId = $commandToServiceIdMapping; } /** * Retrieves the handler for a specified command * * @param string $commandName * @return object * * @throws MissingHandlerException */ public function getHandlerForCommand($commandName) { if (!isset($this->commandToServiceId[$commandName])) { throw MissingHandlerException::forCommand($commandName); } return $this->container->get($this->commandToServiceId[$commandName]); } }