ResponseMultiBulkStreamHandler.php 634 B

1234567891011121314151617181920
  1. <?php
  2. namespace Predis\Protocols;
  3. use Predis\Utils;
  4. use Predis\ProtocolException;
  5. use Predis\Network\IConnectionComposable;
  6. use Predis\Iterators\MultiBulkResponseSimple;
  7. class ResponseMultiBulkStreamHandler implements IResponseHandler {
  8. public function handle(IConnectionComposable $connection, $lengthString) {
  9. $length = (int) $lengthString;
  10. if ($length != $lengthString) {
  11. Utils::onCommunicationException(new ProtocolException(
  12. $connection, "Cannot parse '$length' as data length"
  13. ));
  14. }
  15. return new MultiBulkResponseSimple($connection, $length);
  16. }
  17. }