original_string: public static function getUniqFilename($filename = '', $dir = null, $force_file = true, $extension = 'txt')
      {
          if (empty($filename)) {
              return '';
          }
          $extension = trim($extension, '.');
  
          if (empty($filename)){
              $filename = uniqid();
              if ($force_file) $filename .= '.'.$extension;
          }
          if (is_null($dir)) {
              $dir = defined('_DIR_TMP') ? _DIR_TMP : '/tmp';
          }
          $dir = Directory::slashDirname($dir);
          $_ext = self::getExtension($filename, true);
          $_fname = str_replace($_ext, '', $filename);
          $i = 0;
          while (file_exists($dir.$_fname.$_ext)) {
              $_fname .= ($i==0 ? '_' : '').rand(10, 99);
              $i++;
          }
          return $_fname.$_ext;
      }
code: public static function getUniqFilename($filename = '', $dir = null, $force_file = true, $extension = 'txt')
      {
          if (empty($filename)) {
              return '';
          }
          $extension = trim($extension, '.');
  
          if (empty($filename)){
              $filename = uniqid();
              if ($force_file) $filename .= '.'.$extension;
          }
          if (is_null($dir)) {
              $dir = defined('_DIR_TMP') ? _DIR_TMP : '/tmp';
          }
          $dir = Directory::slashDirname($dir);
          $_ext = self::getExtension($filename, true);
          $_fname = str_replace($_ext, '', $filename);
          $i = 0;
          while (file_exists($dir.$_fname.$_ext)) {
              $_fname .= ($i==0 ? '_' : '').rand(10, 99);
              $i++;
          }
          return $_fname.$_ext;
      }
code_tokens: public static function getUniqFilename ( $ filename = '' , $ dir = null , $ force_file = true , $ extension = 'txt' ) { if ( empty ( $ filename ) ) { return '' ; } $ extension = trim ( $ extension , '.' ) ; if ( empty ( $ filename ) ) { $ filename = uniqid ( ) ; if ( $ force_file ) $ filename .= '.' . $ extension ; } if ( is_null ( $ dir ) ) { $ dir = defined ( '_DIR_TMP' ) ? _DIR_TMP : '/tmp' ; } $ dir = Directory :: slashDirname ( $ dir ) ; $ _ext = self :: getExtension ( $ filename , true ) ; $ _fname = str_replace ( $ _ext , '' , $ filename ) ; $ i = 0 ; while ( file_exists ( $ dir . $ _fname . $ _ext ) ) { $ _fname .= ( $ i == 0 ? '_' : '' ) . rand ( 10 , 99 ) ; $ i ++ ; } return $ _fname . $ _ext ; }
docstring: Returns a filename or directory that does not exist in the destination
  
  @param   string  $filename       The name of the file or folder you want to create
  @param   string  $dir            The destination directory
  @param   boolean $force_file     Should we force the creation of a file, adding an extension? (TRUE by default)
  @param   string  $extension      The extension to add in the case of a file
  @return  string  The filename or directory, with a possible addition to be sure that it does not exist in the destination directory
docstring_tokens: Returns a filename or directory that does not exist in the destination