ApiGen\Utils\FileSystem::purgeDir PHP Метод

purgeDir() публичный метод

public purgeDir ( string $path )
$path string
    public function purgeDir($path)
    {
        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }
        foreach (Finder::find('*')->from($path)->childFirst() as $item) {
            /** @var \SplFileInfo $item */
            if ($item->isDir()) {
                rmdir($item);
            } else {
                unlink($item);
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * @param string $destination
  */
 private function cleanDestinationWithCaution($destination)
 {
     if (!$this->fileSystem->isDirEmpty($destination)) {
         if ($this->io->ask('<warning>Destination is not empty. Do you want to erase it?</warning>', true)) {
             $this->fileSystem->purgeDir($destination);
         }
     }
 }