@param CommandInterface $command

@return mixed
551327
public function run(CommandInterface $command)
    {
        $result = null;

        /** @var RunnerInterface $runner */
        foreach($this->runners as $runner) {
            $result = $runner->run($command, $result);
        }

        return $result;
    }
971132
public function handle(CommandInterface $command)
    {
        $class = $command->getParameter('class');
        $object = $command->hasParameter('object') ? $command->getParameter('object') : null;

        // if no object has been given, try loading it using a query object
        if (!$object) {
            $object = $this->queryExecutor->execute($command->getParameter('query_object'));
        }

        // try removing the object if it is valid
        if ($object instanceof $class) {
            try {
                $this->objectManager->remove($object);
                $this->objectManager->flush();
            } catch (ForeignKeyConstraintViolationException $e) {
                return CommandResult::error('constraint_violation');
            }
        }
    }
584367
protected function checkCommandType(CommandInterface $command)
    {
        $expectedCommandClass = $this->getCommandClass();
        if (!is_a($command, $expectedCommandClass, true)) {
            $actualCommandClass      = get_class($command);
            $handlerClass            = get_called_class();
            $invalidCommandException = new InvalidCommandException(
                "Command handler '$handlerClass' should only be registered to handle '$expectedCommandClass' commands"
            );
            $this->logError(
                "{$handlerClass} cannot handle commands of type {$actualCommandClass}",
                $invalidCommandException
            );
            throw $invalidCommandException;
        }
    }
947295
protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $error)
    {
        $details = explode(' ', $error->getMessage(), 2);

        switch ($details[0]) {
            case 'MOVED':
                return $this->onMovedResponse($command, $details[1]);

            case 'ASK':
                return $this->onAskResponse($command, $details[1]);

            default:
                return $error;
        }
    }
1077481
public function findHandler(Command $command)
    {
        $command_name = get_class($command);

        return isset($this->handlers[$command_name]) ? $this->handlers[$command_name] : null;
    }
221583
public function add(CommandInterface $command)
    {
        $this->sequence[] = $command;

        if ($this->hasConfig()) {
            $command->setConfig($this->getConfig());
        }

        return $this;
    }
1351944
private function detectPool(CommandInterface $command)
    {
        $commandClass = get_class($command);
        return $this->poolDetector->detect($commandClass);
    }
774847
public function resolve(Command $command)
    {
        $commandName = get_class($command);

        // Find the CommandHandler if it has been manually defined using pushHandler()
        foreach ($this->handlers as $handlerCommand => $handler) {
            if ($handlerCommand == $commandName) {
                return $handler;
            }
        }

        // If the Command also implements CommandHandler, then it can handle() itself
        if ($command instanceof CommandHandler) {
            return $command;
        }

        // Try and guess the handler's name in the same namespace with suffix "Handler"
        $class = $commandName . 'Handler';
        if (class_exists($class)) {
            return $this->container->make($class);
        }

        // Try and guess the handler's name in nested "Handlers" namespace with suffix "Handler"
        $classParts = explode('\\', $commandName);
        $commandNameWithoutNamespace = array_pop($classParts);
        $class = implode('\\', $classParts) . '\\Handlers\\' . $commandNameWithoutNamespace . 'Handler';
        if (class_exists($class)) {
            return $this->container->make($class);
        }

        throw new UnresolvableCommandHandlerException('Could not resolve a handler for [' . get_class($command) . ']');
    }
1021166
public function queue(CommandInterface $command, array $options = [])
    {
        $queueName = null;

        if (array_key_exists(self::QUEUE_OPTION_NAME, $options)) {
            $queueName = $options[self::QUEUE_OPTION_NAME] ?: null;
            unset($options[self::QUEUE_OPTION_NAME]);
        }

	    $queue = $this->getQueue($queueName);

	    if ($command->getIdentity()) {
	        $identity = $command->getIdentity();
	    } else if ($this->getDefaultIdentity()) {
	        $identity = $this->getDefaultIdentity();
	    } else {
	        $identity = null;
	    }

	    if (method_exists($identity, 'toArray')) {
	        $identity = $identity->toArray();
	    } else if ($identity instanceof \ArrayObject) {
	        $identity = $identity->getArrayCopy();
	    }

	    $job = new ServiceJob();
	    $job->setup($command, $identity);
	    $job->setServiceBroker($this);

	    $queue->push($job, $options);
	    return $job;
	}
828284
protected function createRequest(CommandInterface $command)
    {
        $operation = $this->description->getOperation($command->getName());

        // If command does not specify a template, assume the client's base URL.
        if (null === $operation->getUri()) {
            return new Request(
                $operation->getHttpMethod(),
                $this->description->getBaseUri()
            );
        }

        return $this->createCommandWithUri($operation, $command);
    }
184130
public function handle(Command $command)
    {
        $handler = $this->container->make($this->handlerName);

        return $handler->handle($command);
    }
1086780
protected function getKeyFromGeoradiusCommands(CommandInterface $command)
    {
        $arguments = $command->getArguments();
        $argc = count($arguments);
        $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;

        if ($argc > $startIndex) {
            $keys = array($arguments[0]);

            for ($i = $startIndex; $i < $argc; ++$i) {
                $argument = strtoupper($arguments[$i]);
                if ($argument === 'STORE' || $argument === 'STOREDIST') {
                    $keys[] = $arguments[++$i];
                }
            }

            if ($this->checkSameSlotForKeys($keys)) {
                return $arguments[0];
            } else {
                return;
            }
        }

        return $arguments[0];
    }
658825
public function getProcessor(CommandInterface $command)
    {
        $className = get_class($command);
        try {
            return parent::getProcessor($command);
        } catch (ProcessorNotFoundException $ex) {
            if (!array_key_exists($className, $this->serviceIds)) {
                throw new InvalidArgumentException('No processor registered for given type: '.$className.'.', 500, $ex);
            }
            $this->registerProcessorForCommand($className, $this->container->get($this->serviceIds[$className]));
        }

        return parent::getProcessor($command);
    }
32617
public function register(CommandInterface $command)
    {
        /*
         * Gets the name of the command
         * @var string
         */
        $name = $command->getCommand();

        /*
         * Check if the command isn't already registered
         * otherwise throw an exception
         */
        if (array_key_exists($name, $this->commands)) {
            throw new CommandException("Command with name '$name' already registered");
        }

        /*
         * Adds the command to the array
         */
        $this->commands[$name] = $command;
    }
1257621
public function dryRunCommand(CommandInterface $command)
    {
        $this->newLine();
        $this->write(' // Dry-run: ' . $command->getName());
        $this->newLine(3);
    }
1058565
public function findCommandHandlerFor(Command $command)
    {
        if (!isset($this->subscriptions[$command->commandName()])) {
            throw new CommandHandlerNotFoundException(sprintf('No handler was found for command %s', $command->commandName()));
        }

        return $this->subscriptions[$command->commandName()];
    }
543964
public function doRun(InputInterface $input, OutputInterface $output) : int
    {
        $output->setDecorated(false);
        $input->setInteractive(false);

        $command = $this->createCommand();
        return $command->run($input, $output);
    }