ResponseMultiBulkStreamHandler.php 695 B

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