mirror of
https://github.com/predis/predis.git
synced 2026-09-12 11:27:05 +00:00
Reuse code a bit.
This commit is contained in:
+8
-3
@@ -644,6 +644,7 @@ class ResponseReader {
|
||||
public function read(IConnectionSingle $connection) {
|
||||
$header = $connection->readLine();
|
||||
if ($header === '') {
|
||||
$this->throwMalformedResponse('Unexpected empty header');
|
||||
Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, 'Unexpected empty header'
|
||||
));
|
||||
@@ -651,13 +652,17 @@ class ResponseReader {
|
||||
|
||||
$prefix = $header[0];
|
||||
if (!isset($this->_prefixHandlers[$prefix])) {
|
||||
Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, "Unknown prefix '$prefix'"
|
||||
));
|
||||
$this->throwMalformedResponse("Unknown prefix '$prefix'");
|
||||
}
|
||||
$handler = $this->_prefixHandlers[$prefix];
|
||||
return $handler->handle($connection, substr($header, 1));
|
||||
}
|
||||
|
||||
private function throwMalformedResponse($message) {
|
||||
Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, $message
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class ResponseError {
|
||||
|
||||
Reference in New Issue
Block a user