@param CommandInterface $command

@throw \LogicException
@throw \GuzzleHttp\Exception\RequestException

@return \GuzzleHttp\Message\ResponseInterface|void
13561
public function request(CommandInterface $command)
    {
        if ($command instanceof MultipartDocumentUpload) {
            return $command->execute($this->uploadClient);
        }

        return $command->execute($this->apiClient);
    }
197078
public function run(CommandInterface $command, $result = null)
    {
        if(!$result instanceof ResponseInterface) {
            throw new \InvalidArgumentException(
                'The result needs to be an instance of GuzzleHttp\Message\ResponseInterface');
        }

        return json_decode($result->getBody()->getContents(), true);
    }
50310
protected function resolveCommandHandler(CommandInterface $command): CommandHandlerInterface
	{
		$class = get_class($command);

		// Build handler class name

		$commandSuffixLength = strlen(static::COMMAND_SUFFIX);

		if(static::COMMAND_SUFFIX === substr($class, -$commandSuffixLength))
		{
			$handler = substr_replace($class, static::HANDLER_SUFFIX, strrpos($class, static::COMMAND_SUFFIX), $commandSuffixLength);
		}
		else
		{
			$handler = $class . static::HANDLER_SUFFIX;
		}

		// Return handler instance

		return $this->container->get($handler);
	}
1324448
public function visit(
        CommandInterface $command,
        RequestInterface $request,
        Parameter $param
    ) {
        $value = $command[$param->getName()];

        return $request->withHeader($param->getWireName(), $param->filter($value));
    }
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;
        }
    }
618732
public function execute(interfaces\commands\Command $command)
    {
        $handler = $this->resolver->resolve($command);
        
        return call_user_func([$handler, 'handle'], $command);
    }
1052437
public function executeCommand(CliCommand $command)
    {
        $this->command = $command;
        $this->environment = CliEnvironment::getInstance();

        switch ($command->name) {
            case static::COMMAND_PROVIDER_ALIAS . '-execute':
                $this->cmdExecute();
                exit;
            default:
                throw new \LogicException(
                    'Command named[' . $command->name . '] is not provided by class[' . get_class($this) . '].'
                );
        }
    }
723587
public function execute(Command $command)
    {
        if (!$command->isValid()) {
            throw new Exception('Invalid API command supplied');
        }

        $result = $this->curl()->post($this->getUrl($command), $command->getData());
        $type = $this->getResponseType();

        return new Response($result->getData(), $type);
    }
933426
protected function execute(CommandInterface $command)
    {
        $runner = $this->getCommandRunner();

        $this->lastReturnValue = $runner->run($command);

        $this->checkReturnValue($runner);
    }
1156799
public function handle($command)
    {
        $user = new User();
        $user
            ->setEmail($command->getEmail())
            ->setPassword($command->getPassword())
            ->setRoles($this->registeredUserRoles)
            ->setEnabled(true);

        // validate user
        $errors = $this->validator->validate($user);
        if (count($errors) > 0) {
            $exception = new InvalidCommandException("User is invalid");
            $exception->setConstraintViolationList($errors);
            throw $exception;
        }

        // persist user
        $this->entityManager->persist($user);
        $this->entityManager->flush();

        return $user;
    }
770881
public function prepareCommand(CommandInterface $command)
    {
        $request = parent::prepareCommand($command);
        $request->setHeader('Authorization ','Bearer '. $this->prepareAccessToken());
        return $request;
    }
1024510
protected function hasConditionAndConditionNotMatched(CommandInterface $command): bool
    {
        if (!$this->isConditionalCommand($command) || $this->conditionMatched($command)) {
            return false;
        }

        return true;
    }
680771
public function executeCommandOnNodes(CommandInterface $command)
    {
        $responses = array();

        foreach ($this->pool as $connection) {
            $responses[] = $connection->executeCommand($command);
        }

        return $responses;
    }
700619
public static function onCommand($command, ConstraintViolationListInterface $violations)
    {
        $exception = new static(
            'Validation failed for ' . get_class($command) .
            ' with ' . $violations->count() . ' violation(s).'
        );

        $exception->command    = $command;
        $exception->violations = $violations;

        return $exception;
    }
587455
protected function parseClass(CommandInterface $command)
    {
        // Emit the operation.parse_class event. If a listener injects a 'result' property, then that will be the result
        $event = new CreateResponseClassEvent(array('command' => $command));
        $command->getClient()->getEventDispatcher()->dispatch('command.parse_response', $event);
        if ($result = $event->getResult()) {
            return $result;
        }

        $className = $command->getOperation()->getResponseClass();
        if (!method_exists($className, 'fromCommand')) {
            throw new ResponseClassException("{$className} must exist and implement a static fromCommand() method");
        }

        return $className::fromCommand($command);
    }
1274184
private function setShellCommand($command)
    {
        if (! isset($command)) {
            throw new InvalidArgumentException('Must define a command.');
        }

        if (isset($this->shellCommand) && $this->shellCommand !== $command) {
            throw new LogicException('Cannot redefine command once set!');
        }

        $this->shellCommand = $command;

        return $this;
    }
494661
private function calculateHref(CommandInterface $command, $model)
    {
        $parameters = $this->calculateParameters($command, ModelId::fromModel($model)->getSerialized());
        $href       = '';
        foreach ($parameters as $key => $value) {
            $href .= \sprintf('&%s=%s', $key, $value);
        }

        return $this->addToUrl($href);
    }