original_string: public function importRecords(
          $records,
          $format = 'php',
          $type = 'flat',
          $overwriteBehavior = 'normal',
          $dateFormat = 'YMD',
          $returnContent = 'count',
          $forceAutoNumber = false
      ) {
              
          $data = array (
              'token'         => $this->apiToken,
              'content'       => 'record',
              'returnFormat'  => 'json'
          );
              
          #---------------------------------------
          # Process format
          #---------------------------------------
          $legalFormats = array('csv', 'json', 'odm', 'php', 'xml');
          $data['format'] = $this->processFormatArgument($format, $legalFormats);
          $data['data']   = $this->processImportDataArgument($records, 'records', $format);
          $data['type']   = $this->processTypeArgument($type);
              
          $data['overwriteBehavior'] = $this->processOverwriteBehaviorArgument($overwriteBehavior);
          $data['forceAutoNumber']   = $this->processForceAutoNumberArgument($forceAutoNumber);
          $data['returnContent']     = $this->processReturnContentArgument($returnContent, $forceAutoNumber);
          $data['dateFormat']        = $this->processDateFormatArgument($dateFormat);
          
          $result = $this->connection->callWithArray($data);
  
          $this->processNonExportResult($result);
          
          
          #--------------------------------------------------------------------------
          # Process result, which should either be a count of the records imported,
          # or a list of the record IDs that were imported
          #
          # The result should be a string in JSON for all formats.
          # Need to convert the result to a PHP data structure.
          #--------------------------------------------------------------------------
          $phpResult = json_decode($result, true); // true => return as array instead of object
          
          $jsonError = json_last_error();
          
          switch ($jsonError) {
              case JSON_ERROR_NONE:
                  $result = $phpResult;
                  # If this is a count, then just return the count, and not an
                  # array that has a count index with the count
                  if (isset($result) && is_array($result) && array_key_exists('count', $result)) {
                      $result = $result['count'];
                  }
                  break;
              default:
                  # Hopefully the REDCap API will always return valid JSON, and this
                  # will never happen.
                  $message =  'JSON error ('.$jsonError.') "'.json_last_error_msg().
                      '" while processing import return value: "'.
                  $result.'".';
                  $this->errorHandler->throwException($message, ErrorHandlerInterface::JSON_ERROR);
                  break; // @codeCoverageIgnore
          }
          
          return $result;
      }
code: public function importRecords(
          $records,
          $format = 'php',
          $type = 'flat',
          $overwriteBehavior = 'normal',
          $dateFormat = 'YMD',
          $returnContent = 'count',
          $forceAutoNumber = false
      ) {
              
          $data = array (
              'token'         => $this->apiToken,
              'content'       => 'record',
              'returnFormat'  => 'json'
          );
              
          #---------------------------------------
          # Process format
          #---------------------------------------
          $legalFormats = array('csv', 'json', 'odm', 'php', 'xml');
          $data['format'] = $this->processFormatArgument($format, $legalFormats);
          $data['data']   = $this->processImportDataArgument($records, 'records', $format);
          $data['type']   = $this->processTypeArgument($type);
              
          $data['overwriteBehavior'] = $this->processOverwriteBehaviorArgument($overwriteBehavior);
          $data['forceAutoNumber']   = $this->processForceAutoNumberArgument($forceAutoNumber);
          $data['returnContent']     = $this->processReturnContentArgument($returnContent, $forceAutoNumber);
          $data['dateFormat']        = $this->processDateFormatArgument($dateFormat);
          
          $result = $this->connection->callWithArray($data);
  
          $this->processNonExportResult($result);
          
          
          #--------------------------------------------------------------------------
          # Process result, which should either be a count of the records imported,
          # or a list of the record IDs that were imported
          #
          # The result should be a string in JSON for all formats.
          # Need to convert the result to a PHP data structure.
          #--------------------------------------------------------------------------
          $phpResult = json_decode($result, true); // true => return as array instead of object
          
          $jsonError = json_last_error();
          
          switch ($jsonError) {
              case JSON_ERROR_NONE:
                  $result = $phpResult;
                  # If this is a count, then just return the count, and not an
                  # array that has a count index with the count
                  if (isset($result) && is_array($result) && array_key_exists('count', $result)) {
                      $result = $result['count'];
                  }
                  break;
              default:
                  # Hopefully the REDCap API will always return valid JSON, and this
                  # will never happen.
                  $message =  'JSON error ('.$jsonError.') "'.json_last_error_msg().
                      '" while processing import return value: "'.
                  $result.'".';
                  $this->errorHandler->throwException($message, ErrorHandlerInterface::JSON_ERROR);
                  break; // @codeCoverageIgnore
          }
          
          return $result;
      }
code_tokens: public function importRecords ( $ records , $ format = 'php' , $ type = 'flat' , $ overwriteBehavior = 'normal' , $ dateFormat = 'YMD' , $ returnContent = 'count' , $ forceAutoNumber = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'record' , 'returnFormat' => 'json' ) ; #--------------------------------------- # Process format #--------------------------------------- $ legalFormats = array ( 'csv' , 'json' , 'odm' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ records , 'records' , $ format ) ; $ data [ 'type' ] = $ this -> processTypeArgument ( $ type ) ; $ data [ 'overwriteBehavior' ] = $ this -> processOverwriteBehaviorArgument ( $ overwriteBehavior ) ; $ data [ 'forceAutoNumber' ] = $ this -> processForceAutoNumberArgument ( $ forceAutoNumber ) ; $ data [ 'returnContent' ] = $ this -> processReturnContentArgument ( $ returnContent , $ forceAutoNumber ) ; $ data [ 'dateFormat' ] = $ this -> processDateFormatArgument ( $ dateFormat ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; #-------------------------------------------------------------------------- # Process result, which should either be a count of the records imported, # or a list of the record IDs that were imported # # The result should be a string in JSON for all formats. # Need to convert the result to a PHP data structure. #-------------------------------------------------------------------------- $ phpResult = json_decode ( $ result , true ) ; // true => return as array instead of object $ jsonError = json_last_error ( ) ; switch ( $ jsonError ) { case JSON_ERROR_NONE : $ result = $ phpResult ; # If this is a count, then just return the count, and not an # array that has a count index with the count if ( isset ( $ result ) && is_array ( $ result ) && array_key_exists ( 'count' , $ result ) ) { $ result = $ result [ 'count' ] ; } break ; default : # Hopefully the REDCap API will always return valid JSON, and this # will never happen. $ message = 'JSON error (' . $ jsonError . ') "' . json_last_error_msg ( ) . '" while processing import return value: "' . $ result . '".' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: JSON_ERROR ) ; break ; // @codeCoverageIgnore } return $ result ; }
docstring: Imports the specified records into the project.
  
  @param mixed $records
  If the 'php' (default) format is being used, an array of associated arrays (maps)
  where each key is a field name,
  and its value is the value to store in that field. If any other format is being used, then
  the records are represented by a string.
  @param string $format One of the following formats can be specified
  <ul>
  <li> 'php' - [default] array of maps of values</li>
  <li> 'csv' - string of CSV (comma-separated values)</li>
  <li> 'json' - string of JSON encoded values</li>
  <li> 'xml' - string of XML encoded data</li>
  <li> 'odm' - CDISC ODM XML format, specifically ODM version 1.3.1</li>
  </ul>
  @param string $type
  <ul>
  <li> 'flat' - [default] each data element is a record</li>
  <li> 'eav' - each data element is one value</li>
  </ul>
  @param string $overwriteBehavior
  <ul>
  <li>normal - [default] blank/empty values will be ignored</li>
  <li>overwrite - blank/empty values are valid and will overwrite data</li>
  </ul>
  @param string $dateFormat date format which can be one of the following:
  <ul>
  <li>'YMD' - [default] Y-M-D format (e.g., 2016-12-31)</li>
  <li>'MDY' - M/D/Y format (e.g., 12/31/2016)</li>
  <li>'DMY' - D/M/Y format (e.g., 31/12/2016)</li>
  </ul>
  @param string $returnContent specifies what should be returned:
  <ul>
  <li>'count' - [default] the number of records imported</li>
  <li>'ids' - an array of the record IDs imported is returned</li>
  <li>'auto_ids' - an array of comma-separated record ID pairs, with
  the new ID created and the corresponding ID that
  was sent, for the records that were imported.
  This can only be used if $forceAutoNumber is set to true.</li>
  </ul>
  @param boolean $forceAutoNumber enables automatic assignment of record IDs of imported
  records by REDCap.
  If this is set to true, and auto-numbering for records is enabled for the project,
  auto-numbering of imported records will be enabled.
  
  @return mixed if 'count' was specified for 'returnContent', then an integer will
  be returned that is the number of records imported.
  If 'ids' was specified, then an array of record IDs that were imported will
  be returned. If 'auto_ids' was specified, an array that maps newly created IDs
  to sent IDs will be returned.
docstring_tokens: Imports the specified records into the project .