Пример #1
0
 public function read(Predis_Connection $connection)
 {
     $header = $connection->readLine();
     if ($header === '') {
         Predis_Shared_Utils::onCommunicationException(new Predis_MalformedServerResponse($connection, 'Unexpected empty header'));
     }
     $prefix = $header[0];
     $payload = strlen($header) > 1 ? substr($header, 1) : '';
     if (!isset($this->_prefixHandlers[$prefix])) {
         Predis_Shared_Utils::onCommunicationException(new Predis_MalformedServerResponse($connection, "Unknown prefix '{$prefix}'"));
     }
     $handler = $this->_prefixHandlers[$prefix];
     return $handler->handle($connection, $payload);
 }
Пример #2
0
 public function read(Predis_Connection $connection)
 {
     $header = $connection->readLine();
     if ($header === '') {
         $this->throwMalformedResponse($connection, 'Unexpected empty header');
     }
     $prefix = $header[0];
     if (!isset($this->_prefixHandlers[$prefix])) {
         $this->throwMalformedResponse($connection, "Unknown prefix '{$prefix}'");
     }
     $handler = $this->_prefixHandlers[$prefix];
     return $handler->handle($connection, substr($header, 1));
 }