public function read(IConnectionSingle $connection) { $header = $connection->readLine(); if ($header === '') { Utils::onCommunicationException(new MalformedServerResponse($connection, 'Unexpected empty header')); } $prefix = $header[0]; $payload = strlen($header) > 1 ? substr($header, 1) : ''; if (!isset($this->_prefixHandlers[$prefix])) { Utils::onCommunicationException(new MalformedServerResponse($connection, "Unknown prefix '{$prefix}'")); } $handler = $this->_prefixHandlers[$prefix]; return $handler->handle($connection, $payload); }