code: 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";
      }
docs: Remove wonky characters from a path name
  
  @param string $name The basename to sanitize
  @return string