public static function decodeBody($body, $decode = 'gzip')
    {
        switch ($decode) {
            // GZIP compression
            case 'gzip':
                if (!function_exists('gzinflate')) {
                    throw new \Exception('Gzip compression is not available.');
                }
                $decodedBody = gzinflate(substr($body, 10));
                break;

            // Deflate compression
            case 'deflate':
                if (!function_exists('gzinflate')) {
                    throw new \Exception('Deflate compression is not available.');
                }
                $zlibHeader = unpack('n', substr($body, 0, 2));
                $decodedBody = ($zlibHeader[1] % 31 == 0) ? gzuncompress($body) : gzinflate($body);
                break;

            // Unknown compression
            default:
                $decodedBody = $body;

        }

        return $decodedBody;
    }
public static function decodeBody($body, $decode = 'gzip')
    {
        switch ($decode) {
            // GZIP compression
            case 'gzip':
                if (!function_exists('gzinflate')) {
                    throw new \Exception('Gzip compression is not available.');
                }
                $decodedBody = gzinflate(substr($body, 10));
                break;

            // Deflate compression
            case 'deflate':
                if (!function_exists('gzinflate')) {
                    throw new \Exception('Deflate compression is not available.');
                }
                $zlibHeader = unpack('n', substr($body, 0, 2));
                $decodedBody = ($zlibHeader[1] % 31 == 0) ? gzuncompress($body) : gzinflate($body);
                break;

            // Unknown compression
            default:
                $decodedBody = $body;

        }

        return $decodedBody;
    }
public static function decodeBody ( $ body , $ decode = 'gzip' ) { switch ( $ decode ) { // GZIP compression case 'gzip' : if ( ! function_exists ( 'gzinflate' ) ) { throw new \ Exception ( 'Gzip compression is not available.' ) ; } $ decodedBody = gzinflate ( substr ( $ body , 10 ) ) ; break ; // Deflate compression case 'deflate' : if ( ! function_exists ( 'gzinflate' ) ) { throw new \ Exception ( 'Deflate compression is not available.' ) ; } $ zlibHeader = unpack ( 'n' , substr ( $ body , 0 , 2 ) ) ; $ decodedBody = ( $ zlibHeader [ 1 ] % 31 == 0 ) ? gzuncompress ( $ body ) : gzinflate ( $ body ) ; break ; // Unknown compression default : $ decodedBody = $ body ; } return $ decodedBody ; }
Decode the body data.

@param (mixed)  $body
@param (string) $encode

@since 3.0.0

@return string
Decode the body data .