public static function sanitizeName(string $name): string
    {
        $basename = basename($name);
        $dir = ($basename === $name) ? null : dirname($name);
        $basename = preg_replace("/[^a-zA-Z0-9-_.]/", "_", $basename);
        return ($dir === null) ? $basename : "$dir/$basename";
    }
public static function sanitizeName(string $name): string
    {
        $basename = basename($name);
        $dir = ($basename === $name) ? null : dirname($name);
        $basename = preg_replace("/[^a-zA-Z0-9-_.]/", "_", $basename);
        return ($dir === null) ? $basename : "$dir/$basename";
    }
public static function sanitizeName ( string $ name ) : string { $ basename = basename ( $ name ) ; $ dir = ( $ basename === $ name ) ? null : dirname ( $ name ) ; $ basename = preg_replace ( "/[^a-zA-Z0-9-_.]/" , "_" , $ basename ) ; return ( $ dir === null ) ? $ basename : "$dir/$basename" ; }
Remove wonky characters from a path name

@param string $name The basename to sanitize
@return string
Remove wonky characters from a path name