code: public static function deleteFile($file, array $excludeFiles = [])
      {
          if (!\is_array($excludeFiles)) {
              $excludeFiles = [$excludeFiles];
          }
  
          if (file_exists($file) && is_file($file) && \in_array(basename($file), $excludeFiles, true) === false) {
              @chmod($file, 0777); // NT ?
              unlink($file);
          }
      }
docs: Delete file
  
  @param string $file File path
  @param array $excludeFiles Excluded files