protected function parseResponse($command, $buffer)
    {
        // At this point we retrieve a raw response containing at least a trailing terminator - rip it
        $response = substr($buffer, 0, strlen($buffer) - strlen(self::COMMAND_TERMINATOR));
        $lines    = explode(self::COMMAND_TERMINATOR, $response);
        $result   = false;

        if (
            $command === self::COMMAND_GET ||
            $command === self::COMMAND_GETS
        ) {
            // PARSER for <get> <gets>
            $result = $this->parseReadResponse($buffer, $lines);

        } elseif (
            $command === self::COMMAND_SET     ||
            $command === self::COMMAND_ADD     ||
            $command === self::COMMAND_REPLACE ||
            $command === self::COMMAND_APPEND  ||
            $command === self::COMMAND_PREPEND ||
            $command === self::COMMAND_CAS
        ) {
            // PARSER for <set> <add> <replace> <append> <prepend> <cas>
            $result = $this->parseWriteResponse($buffer, $lines);

        } elseif (
            $command === self::COMMAND_DELETE
        ) {
            // PARSER for <delete>
            $result = $this->parseDeleteResponse($lines);

        } elseif (
            $command === self::COMMAND_STATS
        ) {
            // PARSER for <stats*>
            $result = $this->parseStatsResponse($lines);

        } elseif (
            $command === self::COMMAND_VERSION
        ) {
            // PARSER for <version>
            $result = $this->parseVersionResponse($lines);

        } elseif (
            $command === self::COMMAND_INCR ||
            $command === self::COMMAND_DECR
        ) {
            // PARSER for <incr> & <decr>
            $result = $this->parseArithmeticResponse($buffer, $lines);
        } elseif (
            $command === self::COMMAND_FLUSH_ALL
        ) {
            // PARSER for <flush_all>
            $result = $this->parseFlushResponse($buffer);
        }

        return $result;
    }
protected function parseResponse($command, $buffer)
    {
        // At this point we retrieve a raw response containing at least a trailing terminator - rip it
        $response = substr($buffer, 0, strlen($buffer) - strlen(self::COMMAND_TERMINATOR));
        $lines    = explode(self::COMMAND_TERMINATOR, $response);
        $result   = false;

        if (
            $command === self::COMMAND_GET ||
            $command === self::COMMAND_GETS
        ) {
            // PARSER for <get> <gets>
            $result = $this->parseReadResponse($buffer, $lines);

        } elseif (
            $command === self::COMMAND_SET     ||
            $command === self::COMMAND_ADD     ||
            $command === self::COMMAND_REPLACE ||
            $command === self::COMMAND_APPEND  ||
            $command === self::COMMAND_PREPEND ||
            $command === self::COMMAND_CAS
        ) {
            // PARSER for <set> <add> <replace> <append> <prepend> <cas>
            $result = $this->parseWriteResponse($buffer, $lines);

        } elseif (
            $command === self::COMMAND_DELETE
        ) {
            // PARSER for <delete>
            $result = $this->parseDeleteResponse($lines);

        } elseif (
            $command === self::COMMAND_STATS
        ) {
            // PARSER for <stats*>
            $result = $this->parseStatsResponse($lines);

        } elseif (
            $command === self::COMMAND_VERSION
        ) {
            // PARSER for <version>
            $result = $this->parseVersionResponse($lines);

        } elseif (
            $command === self::COMMAND_INCR ||
            $command === self::COMMAND_DECR
        ) {
            // PARSER for <incr> & <decr>
            $result = $this->parseArithmeticResponse($buffer, $lines);
        } elseif (
            $command === self::COMMAND_FLUSH_ALL
        ) {
            // PARSER for <flush_all>
            $result = $this->parseFlushResponse($buffer);
        }

        return $result;
    }
protected function parseResponse ( $ command , $ buffer ) { // At this point we retrieve a raw response containing at least a trailing terminator - rip it $ response = substr ( $ buffer , 0 , strlen ( $ buffer ) - strlen ( self :: COMMAND_TERMINATOR ) ) ; $ lines = explode ( self :: COMMAND_TERMINATOR , $ response ) ; $ result = false ; if ( $ command === self :: COMMAND_GET || $ command === self :: COMMAND_GETS ) { // PARSER for <get> <gets> $ result = $ this -> parseReadResponse ( $ buffer , $ lines ) ; } elseif ( $ command === self :: COMMAND_SET || $ command === self :: COMMAND_ADD || $ command === self :: COMMAND_REPLACE || $ command === self :: COMMAND_APPEND || $ command === self :: COMMAND_PREPEND || $ command === self :: COMMAND_CAS ) { // PARSER for <set> <add> <replace> <append> <prepend> <cas> $ result = $ this -> parseWriteResponse ( $ buffer , $ lines ) ; } elseif ( $ command === self :: COMMAND_DELETE ) { // PARSER for <delete> $ result = $ this -> parseDeleteResponse ( $ lines ) ; } elseif ( $ command === self :: COMMAND_STATS ) { // PARSER for <stats*> $ result = $ this -> parseStatsResponse ( $ lines ) ; } elseif ( $ command === self :: COMMAND_VERSION ) { // PARSER for <version> $ result = $ this -> parseVersionResponse ( $ lines ) ; } elseif ( $ command === self :: COMMAND_INCR || $ command === self :: COMMAND_DECR ) { // PARSER for <incr> & <decr> $ result = $ this -> parseArithmeticResponse ( $ buffer , $ lines ) ; } elseif ( $ command === self :: COMMAND_FLUSH_ALL ) { // PARSER for <flush_all> $ result = $ this -> parseFlushResponse ( $ buffer ) ; } return $ result ; }
Parses a response from a Memcached daemon

@param string $command The command which has triggered the buffer response from instance.
@param string $buffer  The buffer to parse.

@author Benjamin Carl <opensource@clickalicious.de>
@return bool|mixed FALSE on error, otherwise parsed response
@access protected
@throws \Clickalicious\Memcached\Exception
Parses a response from a Memcached daemon