src/Build/Builder.php
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;
    }
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;
    }
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 ; }
Remove the contents of a directory, but not the directory itself.

@param string $dir
@param bool $preserveGit
@return bool
Remove the contents of a directory but not the directory itself .