public function clean($dir, $preserveGit = false)
    {
        $filesystem = new Filesystem();

        if ( ! $filesystem->exists($dir)) {
            return $filesystem->makeDirectory($dir, 0755, true);
        }

        foreach (new FilesystemIterator($dir) as $file) {
            if ($preserveGit && $file->getFilename() == '.git') {
                continue;
            }
            if ($file->isDir() && ! $file->isLink()) {
                $filesystem->deleteDirectory($file);
            } else {
                $filesystem->delete($file);
            }
        }

        return true;
    }