Box\Spout\Common\Helper\FileSystemHelper::deleteFolderRecursively PHP Method

deleteFolderRecursively() public method

Delete the folder at the given path as well as all its contents
public deleteFolderRecursively ( string $folderPath ) : void
$folderPath string Path of the folder to delete
return void
    public function deleteFolderRecursively($folderPath)
    {
        $this->throwIfOperationNotInBaseFolder($folderPath);
        $itemIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($folderPath, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($itemIterator as $item) {
            if ($item->isDir()) {
                rmdir($item->getPathname());
            } else {
                unlink($item->getPathname());
            }
        }
        rmdir($folderPath);
    }