Skip to content

Commit 31dc875

Browse files
committed
remove dir
1 parent ca4a5b1 commit 31dc875

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/FileSystem/DirHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,21 @@ public function deleteFile(string $name): bool {
251251
* @param string|null $name
252252
* @return bool
253253
*/
254-
public function rmdir(string $name = null): bool {
255-
$iterator = new RecursiveDirectoryIterator(
254+
public function rmdir(): bool {
255+
$itemsDeleted = false;
256+
$iterator = new RecursiveDirectoryIterator(
256257
$this->getPath()
257258
);
258259

259260
/** @var SplFileInfo $item */
260261
foreach ($iterator as $item) {
261-
if (false === $item->isDir()) continue;
262-
if ($item->getBasename() === $name) {
263-
unlink($item->getRealPath());
264-
return true;
265-
}
262+
$itemDeleted = unlink($item->getRealPath());
263+
$itemsDeleted = $itemsDeleted && $itemDeleted;
266264
}
267265

268-
return false;
266+
$pathDeleted = unlink($this->getPath());
267+
268+
return true === $itemsDeleted && true === $pathDeleted;
269269
}
270270

271271
}

0 commit comments

Comments
 (0)