Exemplo n.º 1
0
 /**
  * Removes all files and directories that are set to be
  * automatically removed.
  *
  * @param  $destinationDirectory
  * @return array
  */
 private function removeFilesAndDirectories($destinationDirectory)
 {
     $currentStructure = $this->fileSystem->allFiles($destinationDirectory);
     $removedPaths = [];
     foreach ($currentStructure as $file) {
         /* @var SplFileInfo $file */
         $directoryPath = $this->normalizePath($destinationDirectory . DIRECTORY_SEPARATOR . $file->getRelativePath());
         $fullPath = $this->normalizePath($destinationDirectory . DIRECTORY_SEPARATOR . $file->getRelativePathname());
         if ($this->shouldBeRemoved($directoryPath)) {
             $removedPaths[] = $directoryPath;
             $this->fileSystem->deleteDirectory($directoryPath, false);
         }
         if ($this->shouldBeRemoved($fullPath)) {
             $removedPaths[] = $fullPath;
             $this->fileSystem->delete($fullPath);
         }
     }
     return $removedPaths;
 }