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;
    }