public function set($data)
    {
        $this->error = [];
        $result = null;
        switch ($this->format) {
            case 'nvp':
                parse_str($data, $this->data);
                $result = !empty($this->data);
                break;

            case 'json':
            default:
                $this->data = empty($data) ? [] : (json_decode($data, true) ?: []);
                $result = json_last_error() == JSON_ERROR_NONE;
                if (empty ($result)) {
                    $this->error = [
                        'error' => json_last_error(),
                        'msg'   => json_last_error_msg(),
                    ];
                }
                break;
        }

        return $result;
    }
public function set($data)
    {
        $this->error = [];
        $result = null;
        switch ($this->format) {
            case 'nvp':
                parse_str($data, $this->data);
                $result = !empty($this->data);
                break;

            case 'json':
            default:
                $this->data = empty($data) ? [] : (json_decode($data, true) ?: []);
                $result = json_last_error() == JSON_ERROR_NONE;
                if (empty ($result)) {
                    $this->error = [
                        'error' => json_last_error(),
                        'msg'   => json_last_error_msg(),
                    ];
                }
                break;
        }

        return $result;
    }
public function set ( $ data ) { $ this -> error = [ ] ; $ result = null ; switch ( $ this -> format ) { case 'nvp' : parse_str ( $ data , $ this -> data ) ; $ result = ! empty ( $ this -> data ) ; break ; case 'json' : default : $ this -> data = empty ( $ data ) ? [ ] : ( json_decode ( $ data , true ) ? : [ ] ) ; $ result = json_last_error ( ) == JSON_ERROR_NONE ; if ( empty ( $ result ) ) { $ this -> error = [ 'error' => json_last_error ( ) , 'msg' => json_last_error_msg ( ) , ] ; } break ; } return $ result ; }
Set API response
- decode from JSON.

@param string $data
@throws RuntimeException
@return bool
Set API response - decode from JSON .