original_string: public function addQuery(Search $query, $modeManualAction = null) {
          if($modeManualAction && $this->data['mode'] != 'manual') {
              throw new \InvalidArgumentException('Query mode must be set to "manual" before using a batchAction for queries.');
          }
  	    //add query data
  	    $queryArray = json_decode($query->getData(), true);
  	    //add batchAction if any
  	    if($modeManualAction) {
  	        $queryArray['batchAction'] = $modeManualAction;
  	    }
          //add template if any
  	    $template = $query->getTemplate();
  	    if(!empty($template)) {
  	        $queryArray['template'] = $template;
  	        $suffix = 'Template';
  	    } else { 
              $suffix = '';	        
  	    }
      	//add type of query
      	$type = get_class($query);
  	    switch($type) {
  	        case 'OpenSearchServer\Search\Field\Search':
      	        $queryArray['type'] = 'SearchField'.$suffix;
          	    break;
  	        case 'OpenSearchServer\Search\Pattern\Search':
          	    $queryArray['type'] = 'SearchPattern'.$suffix;
          	    break;
  	    }
  	    $this->data['queries'][] = $queryArray;
  	}
code: public function addQuery(Search $query, $modeManualAction = null) {
          if($modeManualAction && $this->data['mode'] != 'manual') {
              throw new \InvalidArgumentException('Query mode must be set to "manual" before using a batchAction for queries.');
          }
  	    //add query data
  	    $queryArray = json_decode($query->getData(), true);
  	    //add batchAction if any
  	    if($modeManualAction) {
  	        $queryArray['batchAction'] = $modeManualAction;
  	    }
          //add template if any
  	    $template = $query->getTemplate();
  	    if(!empty($template)) {
  	        $queryArray['template'] = $template;
  	        $suffix = 'Template';
  	    } else { 
              $suffix = '';	        
  	    }
      	//add type of query
      	$type = get_class($query);
  	    switch($type) {
  	        case 'OpenSearchServer\Search\Field\Search':
      	        $queryArray['type'] = 'SearchField'.$suffix;
          	    break;
  	        case 'OpenSearchServer\Search\Pattern\Search':
          	    $queryArray['type'] = 'SearchPattern'.$suffix;
          	    break;
  	    }
  	    $this->data['queries'][] = $queryArray;
  	}
code_tokens: public function addQuery ( Search $ query , $ modeManualAction = null ) { if ( $ modeManualAction && $ this -> data [ 'mode' ] != 'manual' ) { throw new \ InvalidArgumentException ( 'Query mode must be set to "manual" before using a batchAction for queries.' ) ; } //add query data $ queryArray = json_decode ( $ query -> getData ( ) , true ) ; //add batchAction if any if ( $ modeManualAction ) { $ queryArray [ 'batchAction' ] = $ modeManualAction ; } //add template if any $ template = $ query -> getTemplate ( ) ; if ( ! empty ( $ template ) ) { $ queryArray [ 'template' ] = $ template ; $ suffix = 'Template' ; } else { $ suffix = '' ; } //add type of query $ type = get_class ( $ query ) ; switch ( $ type ) { case 'OpenSearchServer\Search\Field\Search' : $ queryArray [ 'type' ] = 'SearchField' . $ suffix ; break ; case 'OpenSearchServer\Search\Pattern\Search' : $ queryArray [ 'type' ] = 'SearchPattern' . $ suffix ; break ; } $ this -> data [ 'queries' ] [ ] = $ queryArray ; }
docstring: Add one query to the batch
  @param Search $query
  @param String $modeManualAction Batch action to use for the query, if mode is "manual"
docstring_tokens: Add one query to the batch