mirror of
https://github.com/predis/predis.git
synced 2026-08-30 20:21:31 +00:00
Reuse code a bit.
This commit is contained in:
+8
-6
@@ -686,20 +686,22 @@ class ResponseReader {
|
||||
public function read(Connection $connection) {
|
||||
$header = $connection->readLine();
|
||||
if ($header === '') {
|
||||
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, 'Unexpected empty header'
|
||||
));
|
||||
$this->throwMalformedResponse($connection, 'Unexpected empty header');
|
||||
}
|
||||
|
||||
$prefix = $header[0];
|
||||
if (!isset($this->_prefixHandlers[$prefix])) {
|
||||
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, "Unknown prefix '$prefix'"
|
||||
));
|
||||
$this->throwMalformedResponse($connection, "Unknown prefix '$prefix'");
|
||||
}
|
||||
$handler = $this->_prefixHandlers[$prefix];
|
||||
return $handler->handle($connection, substr($header, 1));
|
||||
}
|
||||
|
||||
private function throwMalformedResponse(Connection $connection, $message) {
|
||||
Shared\Utils::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, $message
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class ResponseError {
|
||||
|
||||
Reference in New Issue
Block a user