protected function processExportResult(& $result, $format)
    {
        if ($format == 'php') {
            $phpResult = json_decode($result, true); // true => return as array instead of object
                
            $jsonError = json_last_error();
                
            switch ($jsonError) {
                case JSON_ERROR_NONE:
                    $result = $phpResult;
                    break;
                default:
                    $message =  "JSON error (" . $jsonError . ") \"" . json_last_error_msg()
                        ."\" in REDCap API output."
                        ."\nThe first 1,000 characters of output returned from REDCap are:\n"
                        .substr($result, 0, 1000);
                    $code = ErrorHandlerInterface::JSON_ERROR;
                    $this->errorHandler->throwException($message, $code);
                    break; // @codeCoverageIgnore
            }
                
            if (array_key_exists('error', $result)) {
                $this->errorHandler->throwException($result ['error'], ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        } else {
            // If this is a format other than 'php', look for a JSON error, because
            // all formats return errors as JSON
            $matches = array();
            $hasMatch = preg_match(self::JSON_RESULT_ERROR_PATTERN, $result, $matches);
            if ($hasMatch === 1) {
                // note: $matches[0] is the complete string that matched
                //       $matches[1] is just the error message part
                $message = $matches[1];
                $this->errorHandler->throwException($message, ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        }
        
        return $result;
    }
protected function processExportResult(& $result, $format)
    {
        if ($format == 'php') {
            $phpResult = json_decode($result, true); // true => return as array instead of object
                
            $jsonError = json_last_error();
                
            switch ($jsonError) {
                case JSON_ERROR_NONE:
                    $result = $phpResult;
                    break;
                default:
                    $message =  "JSON error (" . $jsonError . ") \"" . json_last_error_msg()
                        ."\" in REDCap API output."
                        ."\nThe first 1,000 characters of output returned from REDCap are:\n"
                        .substr($result, 0, 1000);
                    $code = ErrorHandlerInterface::JSON_ERROR;
                    $this->errorHandler->throwException($message, $code);
                    break; // @codeCoverageIgnore
            }
                
            if (array_key_exists('error', $result)) {
                $this->errorHandler->throwException($result ['error'], ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        } else {
            // If this is a format other than 'php', look for a JSON error, because
            // all formats return errors as JSON
            $matches = array();
            $hasMatch = preg_match(self::JSON_RESULT_ERROR_PATTERN, $result, $matches);
            if ($hasMatch === 1) {
                // note: $matches[0] is the complete string that matched
                //       $matches[1] is just the error message part
                $message = $matches[1];
                $this->errorHandler->throwException($message, ErrorHandlerInterface::REDCAP_API_ERROR);
            } // @codeCoverageIgnore
        }
        
        return $result;
    }
protected function processExportResult ( & $ result , $ format ) { if ( $ format == 'php' ) { $ phpResult = json_decode ( $ result , true ) ; // true => return as array instead of object $ jsonError = json_last_error ( ) ; switch ( $ jsonError ) { case JSON_ERROR_NONE : $ result = $ phpResult ; break ; default : $ message = "JSON error (" . $ jsonError . ") \"" . json_last_error_msg ( ) . "\" in REDCap API output." . "\nThe first 1,000 characters of output returned from REDCap are:\n" . substr ( $ result , 0 , 1000 ) ; $ code = ErrorHandlerInterface :: JSON_ERROR ; $ this -> errorHandler -> throwException ( $ message , $ code ) ; break ; // @codeCoverageIgnore } if ( array_key_exists ( 'error' , $ result ) ) { $ this -> errorHandler -> throwException ( $ result [ 'error' ] , ErrorHandlerInterface :: REDCAP_API_ERROR ) ; } // @codeCoverageIgnore } else { // If this is a format other than 'php', look for a JSON error, because // all formats return errors as JSON $ matches = array ( ) ; $ hasMatch = preg_match ( self :: JSON_RESULT_ERROR_PATTERN , $ result , $ matches ) ; if ( $ hasMatch === 1 ) { // note: $matches[0] is the complete string that matched //       $matches[1] is just the error message part $ message = $ matches [ 1 ] ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: REDCAP_API_ERROR ) ; } // @codeCoverageIgnore } return $ result ; }
Processes an export result from the REDCap API.

@param string $result
@param string $format
@throws PhpCapException
Processes an export result from the REDCap API .