src/File.php
public function removeDirectory($recursive = false)
	{
		if (!$recursive) {
			return rmdir($this->path);
		}

		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) {
			$path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname());
		}

		return true;
	}
public function removeDirectory($recursive = false)
	{
		if (!$recursive) {
			return rmdir($this->path);
		}

		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) {
			$path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname());
		}

		return true;
	}
Returns true if the directory is succesfully removed.

@param bool $recursive = false
@return bool true if the directory is succesfully removed.