original_string: public static function formatFilename($filename = '', $lowercase = false, $delimiter = '-')
      {
          if (empty($filename)) {
              return '';
          }
  
          $_ext = self::getExtension($filename, true);
          if ($_ext) {
              $filename = str_replace($_ext, '', $filename);
          }
  
          $string = $filename;
          if ($lowercase) {
              $string = strtolower($string);
          }
  
          $string = str_replace(" ",$delimiter,$string);
          $string = preg_replace('#\-+#',$delimiter,$string);
          $string = preg_replace('#([-]+)#',$delimiter,$string);
          $string = trim($string,$delimiter);
  
          $string = TextHelper::stripSpecialChars($string, $delimiter.'.');
  
          if ($_ext) {
              $string .= $_ext;
          }
  
          return $string;
      }
code: public static function formatFilename($filename = '', $lowercase = false, $delimiter = '-')
      {
          if (empty($filename)) {
              return '';
          }
  
          $_ext = self::getExtension($filename, true);
          if ($_ext) {
              $filename = str_replace($_ext, '', $filename);
          }
  
          $string = $filename;
          if ($lowercase) {
              $string = strtolower($string);
          }
  
          $string = str_replace(" ",$delimiter,$string);
          $string = preg_replace('#\-+#',$delimiter,$string);
          $string = preg_replace('#([-]+)#',$delimiter,$string);
          $string = trim($string,$delimiter);
  
          $string = TextHelper::stripSpecialChars($string, $delimiter.'.');
  
          if ($_ext) {
              $string .= $_ext;
          }
  
          return $string;
      }
code_tokens: public static function formatFilename ( $ filename = '' , $ lowercase = false , $ delimiter = '-' ) { if ( empty ( $ filename ) ) { return '' ; } $ _ext = self :: getExtension ( $ filename , true ) ; if ( $ _ext ) { $ filename = str_replace ( $ _ext , '' , $ filename ) ; } $ string = $ filename ; if ( $ lowercase ) { $ string = strtolower ( $ string ) ; } $ string = str_replace ( " " , $ delimiter , $ string ) ; $ string = preg_replace ( '#\-+#' , $ delimiter , $ string ) ; $ string = preg_replace ( '#([-]+)#' , $ delimiter , $ string ) ; $ string = trim ( $ string , $ delimiter ) ; $ string = TextHelper :: stripSpecialChars ( $ string , $ delimiter . '.' ) ; if ( $ _ext ) { $ string .= $ _ext ; } return $ string ; }
docstring: Formatting file names
  
  @param   string  $filename   The filename to format
  @param   boolean $lowercase  Should we return the name un lowercase (FALSE by default)
  @param   string  $delimiter  The delimiter used for special chars substitution
  @return  string  A filename valid on (almost) all systems
docstring_tokens: Formatting file names