Skip to content

Commit

Permalink
remove dir
Browse files Browse the repository at this point in the history
  • Loading branch information
doganoo committed Oct 12, 2019
1 parent ca4a5b1 commit 31dc875
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/FileSystem/DirHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,21 @@ public function deleteFile(string $name): bool {
* @param string|null $name
* @return bool
*/
public function rmdir(string $name = null): bool {
$iterator = new RecursiveDirectoryIterator(
public function rmdir(): bool {
$itemsDeleted = false;
$iterator = new RecursiveDirectoryIterator(
$this->getPath()
);

/** @var SplFileInfo $item */
foreach ($iterator as $item) {
if (false === $item->isDir()) continue;
if ($item->getBasename() === $name) {
unlink($item->getRealPath());
return true;
}
$itemDeleted = unlink($item->getRealPath());
$itemsDeleted = $itemsDeleted && $itemDeleted;
}

return false;
$pathDeleted = unlink($this->getPath());

return true === $itemsDeleted && true === $pathDeleted;
}

}

0 comments on commit 31dc875

Please sign in to comment.