original_string: public function start_conversion(stored_file $file, $format, $forcerefresh = false) {
          $conversions = conversion::get_conversions_for_file($file, $format);
  
          if ($forcerefresh || count($conversions) > 1) {
              while ($conversion = array_shift($conversions)) {
                  if ($conversion->get('id')) {
                      $conversion->delete();
                  }
              }
          }
  
          if (empty($conversions)) {
              $conversion = new conversion(0, (object) [
                  'sourcefileid' => $file->get_id(),
                  'targetformat' => $format,
              ]);
              $conversion->create();
          } else {
              $conversion = array_shift($conversions);
          }
  
          if ($conversion->get('status') !== conversion::STATUS_COMPLETE) {
              $this->poll_conversion($conversion);
          }
  
          return $conversion;
      }
code: public function start_conversion(stored_file $file, $format, $forcerefresh = false) {
          $conversions = conversion::get_conversions_for_file($file, $format);
  
          if ($forcerefresh || count($conversions) > 1) {
              while ($conversion = array_shift($conversions)) {
                  if ($conversion->get('id')) {
                      $conversion->delete();
                  }
              }
          }
  
          if (empty($conversions)) {
              $conversion = new conversion(0, (object) [
                  'sourcefileid' => $file->get_id(),
                  'targetformat' => $format,
              ]);
              $conversion->create();
          } else {
              $conversion = array_shift($conversions);
          }
  
          if ($conversion->get('status') !== conversion::STATUS_COMPLETE) {
              $this->poll_conversion($conversion);
          }
  
          return $conversion;
      }
code_tokens: public function start_conversion ( stored_file $ file , $ format , $ forcerefresh = false ) { $ conversions = conversion :: get_conversions_for_file ( $ file , $ format ) ; if ( $ forcerefresh || count ( $ conversions ) > 1 ) { while ( $ conversion = array_shift ( $ conversions ) ) { if ( $ conversion -> get ( 'id' ) ) { $ conversion -> delete ( ) ; } } } if ( empty ( $ conversions ) ) { $ conversion = new conversion ( 0 , ( object ) [ 'sourcefileid' => $ file -> get_id ( ) , 'targetformat' => $ format , ] ) ; $ conversion -> create ( ) ; } else { $ conversion = array_shift ( $ conversions ) ; } if ( $ conversion -> get ( 'status' ) !== conversion :: STATUS_COMPLETE ) { $ this -> poll_conversion ( $ conversion ) ; } return $ conversion ; }
docstring: Start the conversion for a stored_file into a new format.
  
  @param   stored_file $file The file to convert
  @param   string $format The desired target file format (file extension)
  @param   boolean $forcerefresh If true, the file will be converted every time (not cached).
  @return  conversion conversion object
docstring_tokens: Start the conversion for a stored_file into a new format .