code: public function isDirEmpty($dir)
      {
          $finder = Finder::create()
              ->ignoreVCS(false)
              ->ignoreDotFiles(false)
              ->depth(0)
              ->in($dir);
  
          return count($finder) === 0;
      }
docs: Checks if a directory is empty
  
  @param  string $dir
  @return bool