public function executeCommand(CommandInterface $command)
{
$resource = $this->resource;
$commandId = $this->getCommandId($command);
if ($arguments = $command->getArguments()) {
$arguments = implode('/', array_map('urlencode', $arguments));
$serializedCommand = "{$commandId}/{$arguments}.raw";
} else {
$serializedCommand = "{$commandId}.raw";
}
curl_setopt($resource, CURLOPT_POSTFIELDS, $serializedCommand);
if (curl_exec($resource) === false) {
$error = trim(curl_error($resource));
$errno = curl_errno($resource);
throw new ConnectionException($this, "{$error}{$this->getParameters()}]", $errno);
}
if (phpiredis_reader_get_state($this->reader) !== PHPIREDIS_READER_STATE_COMPLETE) {
throw new ProtocolException($this, phpiredis_reader_get_error($this->reader));
}
return phpiredis_reader_get_reply($this->reader);
}