protected function parsePayload($payload)
    {
        $database = 0;
        $client = null;

        $pregCallback = function ($matches) use (&$database, &$client) {
            if (2 === $count = \count($matches)) {
                // Redis <= 2.4
                $database = (int) $matches[1];
            }

            if (4 === $count) {
                // Redis >= 2.6
                $database = (int) $matches[2];
                $client = $matches[3];
            }

            return ' ';
        };

        $event = \preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $pregCallback, $payload, 1);
        @list($timestamp, $command, $arguments) = \explode(' ', $event, 3);

        return (object) [
            'timestamp' => (float) $timestamp,
            'database'  => $database,
            'client'    => $client,
            'command'   => \substr($command, 1, -1),
            'arguments' => $arguments,
        ];
    }
protected function parsePayload($payload)
    {
        $database = 0;
        $client = null;

        $pregCallback = function ($matches) use (&$database, &$client) {
            if (2 === $count = \count($matches)) {
                // Redis <= 2.4
                $database = (int) $matches[1];
            }

            if (4 === $count) {
                // Redis >= 2.6
                $database = (int) $matches[2];
                $client = $matches[3];
            }

            return ' ';
        };

        $event = \preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $pregCallback, $payload, 1);
        @list($timestamp, $command, $arguments) = \explode(' ', $event, 3);

        return (object) [
            'timestamp' => (float) $timestamp,
            'database'  => $database,
            'client'    => $client,
            'command'   => \substr($command, 1, -1),
            'arguments' => $arguments,
        ];
    }
protected function parsePayload ( $ payload ) { $ database = 0 ; $ client = null ; $ pregCallback = function ( $ matches ) use ( & $ database , & $ client ) { if ( 2 === $ count = \ count ( $ matches ) ) { // Redis <= 2.4 $ database = ( int ) $ matches [ 1 ] ; } if ( 4 === $ count ) { // Redis >= 2.6 $ database = ( int ) $ matches [ 2 ] ; $ client = $ matches [ 3 ] ; } return ' ' ; } ; $ event = \ preg_replace_callback ( '/ \(db (\d+)\) | \[(\d+) (.*?)\] /' , $ pregCallback , $ payload , 1 ) ; @ list ( $ timestamp , $ command , $ arguments ) = \ explode ( ' ' , $ event , 3 ) ; return ( object ) [ 'timestamp' => ( float ) $ timestamp , 'database' => $ database , 'client' => $ client , 'command' => \ substr ( $ command , 1 , - 1 ) , 'arguments' => $ arguments , ] ; }
Parses the response string returned by the server into an object.

@param string $payload Payload string.

@return object
Parses the response string returned by the server into an object .