mirror of
https://github.com/predis/predis.git
synced 2026-08-18 13:13:04 +00:00
Removed code duplication.
This commit is contained in:
+10
-10
@@ -322,24 +322,24 @@ class ResponseBulkHandler implements IResponseHandler {
|
||||
|
||||
if ($dataLength > 0) {
|
||||
$value = $connection->readBytes($dataLength);
|
||||
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
|
||||
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, 'Did not receive a new-line at the end of a bulk response'
|
||||
));
|
||||
}
|
||||
self::discardNewLine($connection);
|
||||
return $value;
|
||||
}
|
||||
else if ($dataLength == 0) {
|
||||
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
|
||||
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, 'Did not receive a new-line at the end of a bulk response'
|
||||
));
|
||||
}
|
||||
self::discardNewLine($connection);
|
||||
return '';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function discardNewLine(Connection $connection) {
|
||||
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
|
||||
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
|
||||
$connection, 'Did not receive a new-line at the end of a bulk response'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ResponseMultiBulkHandler implements IResponseHandler {
|
||||
|
||||
Reference in New Issue
Block a user