protected function parseResponse($data, &$exception)
    {
        switch ($this->dataType) {
            case 'json' :
            case 'jsonObject' :
                $result = json_decode($data, $this->dataType === 'json');
                if (null === $result && json_last_error() != JSON_ERROR_NONE) {
                    $exception = new \ErrorException('JSON parsing error, the data is ' . $data, json_last_error());
                }
                break;

            case 'xml' :
            case 'serialize' :
                $methods = array(
                    'xml' => 'simplexml_load_string',
                    'serialize' => 'unserialize',
                );
                $result = @$methods[$this->dataType]($data);
                if (false === $result && $e = error_get_last()) {
                    $exception = new \ErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);
                }
                break;

            case 'query' :
                // Parse $data(string) and assign the result to $result(array)
                parse_str($data, $result);
                break;

            case 'text':
            default :
                $result = $data;
                break;
        }
        return $result;
    }
protected function parseResponse($data, &$exception)
    {
        switch ($this->dataType) {
            case 'json' :
            case 'jsonObject' :
                $result = json_decode($data, $this->dataType === 'json');
                if (null === $result && json_last_error() != JSON_ERROR_NONE) {
                    $exception = new \ErrorException('JSON parsing error, the data is ' . $data, json_last_error());
                }
                break;

            case 'xml' :
            case 'serialize' :
                $methods = array(
                    'xml' => 'simplexml_load_string',
                    'serialize' => 'unserialize',
                );
                $result = @$methods[$this->dataType]($data);
                if (false === $result && $e = error_get_last()) {
                    $exception = new \ErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);
                }
                break;

            case 'query' :
                // Parse $data(string) and assign the result to $result(array)
                parse_str($data, $result);
                break;

            case 'text':
            default :
                $result = $data;
                break;
        }
        return $result;
    }
protected function parseResponse ( $ data , & $ exception ) { switch ( $ this -> dataType ) { case 'json' : case 'jsonObject' : $ result = json_decode ( $ data , $ this -> dataType === 'json' ) ; if ( null === $ result && json_last_error ( ) != JSON_ERROR_NONE ) { $ exception = new \ ErrorException ( 'JSON parsing error, the data is ' . $ data , json_last_error ( ) ) ; } break ; case 'xml' : case 'serialize' : $ methods = array ( 'xml' => 'simplexml_load_string' , 'serialize' => 'unserialize' , ) ; $ result = @ $ methods [ $ this -> dataType ] ( $ data ) ; if ( false === $ result && $ e = error_get_last ( ) ) { $ exception = new \ ErrorException ( $ e [ 'message' ] , $ e [ 'type' ] , 0 , $ e [ 'file' ] , $ e [ 'line' ] ) ; } break ; case 'query' : // Parse $data(string) and assign the result to $result(array) parse_str ( $ data , $ result ) ; break ; case 'text' : default : $ result = $ data ; break ; } return $ result ; }
Parse response data by specified type

@param string $data
@param null $exception A variable to store exception when parsing error
@return mixed
Parse response data by specified type