Sha256: dbeb64b9441facc353d0750d21935bce853b6d75b1c58bd338f2be12806d27e8

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

<?php

namespace Predis\Protocol\Text;

use Predis\Helpers;
use Predis\Protocol\IResponseHandler;
use Predis\Protocol\ProtocolException;
use Predis\Network\IConnectionComposable;

class ResponseMultiBulkHandler implements IResponseHandler {
    public function handle(IConnectionComposable $connection, $lengthString) {
        $length = (int) $lengthString;
        if ($length != $lengthString) {
            Helpers::onCommunicationException(new ProtocolException(
                $connection, "Cannot parse '$length' as data length"
            ));
        }

        if ($length === -1) {
            return null;
        }

        $list = array();
        if ($length > 0) {
            $handlersCache = array();
            $reader = $connection->getProtocol()->getReader();
            for ($i = 0; $i < $length; $i++) {
                $header = $connection->readLine();
                $prefix = $header[0];
                if (isset($handlersCache[$prefix])) {
                    $handler = $handlersCache[$prefix];
                }
                else {
                    $handler = $reader->getHandler($prefix);
                    $handlersCache[$prefix] = $handler;
                }
                $list[$i] = $handler->handle($connection, substr($header, 1));
            }
        }
        return $list;
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appstats-0.25.1 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.25.0 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.24.0 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.23.5 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.23.4 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.23.3 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php
appstats-0.23.2 doc/benchmarks/Predis/Protocol/Text/ResponseMultiBulkHandler.php