original_string: public function set_format_by_file(stored_file $file, $extraformats=null) {
          $this->file = $file;
          $fileformat = portfolio_format_from_mimetype($file->get_mimetype());
          if (is_string($extraformats)) {
              $extraformats = array($extraformats);
          } else if (!is_array($extraformats)) {
              $extraformats = array();
          }
          $this->set_formats(array_merge(array($fileformat), $extraformats));
      }
code: public function set_format_by_file(stored_file $file, $extraformats=null) {
          $this->file = $file;
          $fileformat = portfolio_format_from_mimetype($file->get_mimetype());
          if (is_string($extraformats)) {
              $extraformats = array($extraformats);
          } else if (!is_array($extraformats)) {
              $extraformats = array();
          }
          $this->set_formats(array_merge(array($fileformat), $extraformats));
      }
code_tokens: public function set_format_by_file ( stored_file $ file , $ extraformats = null ) { $ this -> file = $ file ; $ fileformat = portfolio_format_from_mimetype ( $ file -> get_mimetype ( ) ) ; if ( is_string ( $ extraformats ) ) { $ extraformats = array ( $ extraformats ) ; } else if ( ! is_array ( $ extraformats ) ) { $ extraformats = array ( ) ; } $ this -> set_formats ( array_merge ( array ( $ fileformat ) , $ extraformats ) ) ; }
docstring: If we already know we have exactly one file,
  bypass set_formats and just pass the file
  so we can detect the formats by mimetype.
  
  @param stored_file $file file to set the format from
  @param array $extraformats any additional formats other than by mimetype
  eg leap2a etc
docstring_tokens: If we already know we have exactly one file bypass set_formats and just pass the file so we can detect the formats by mimetype .