Parses a raw response and returns a PHP object.
public parseResponse ( string $data ) : mixed | ||
$data | string | Binary string containing the whole response. |
return | mixed |
/** * Handles a response object. * * @param ConnectionInterface $connection * @param CommandInterface $command * @param ResponseObjectInterface $response * @return mixed */ protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response) { if ($response instanceof ResponseErrorInterface) { return $this->onResponseError($connection, $response); } if ($response instanceof Iterator) { return $command->parseResponse(iterator_to_array($response)); } return $response; }
/** * Handles -ERR responses returned by Redis. * * @param CommandInterface $command Redis command that generated the error. * @param ErrorResponseInterface $response Instance of the error response. * * @throws ServerException * * @return mixed */ protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response) { if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') { $eval = $this->createCommand('EVAL'); $eval->setRawArguments($command->getEvalArguments()); $response = $this->executeCommand($eval); if (!$response instanceof ResponseInterface) { $response = $command->parseResponse($response); } return $response; } if ($this->options->exceptions) { throw new ServerException($response->getMessage()); } return $response; }
/** * {@inheritdoc} */ public function readResponse(CommandInterface $command) { $reply = $this->read(); if ($reply instanceof ResponseObjectInterface) { return $reply; } return $command->parseResponse($reply); }