Exemplo n.º 1
0
 /**
  * @param FixtureData $f
  *
  * @return int
  */
 private function remove(FixtureData $f)
 {
     $relativePathName = $f->getFile()->getRelativePathname();
     $relativePath = pathinfo($relativePathName, PATHINFO_DIRNAME);
     $absolutePathName = $f->getFile()->getRealPath();
     $absolutePath = pathinfo($absolutePathName, PATHINFO_DIRNAME);
     $removeDirectory = $this->io()->confirm('Remove directory path and all its contents?', false);
     $removeItem = $removeDirectory === true ? $absolutePath : $absolutePathName;
     $this->io()->caution(sprintf('Remove %s %s', $removeDirectory === true ? 'directory' : 'file', $removeDirectory === true ? $relativePath : $relativePathName));
     if ($this->io()->confirm('Continue with deletion', true) === false) {
         return 1;
     }
     if (!is_writable($removeItem)) {
         $this->io()->error(sprintf('Could not delete "%s"', $relativePathName));
         return 1;
     }
     if ($removeDirectory === true) {
         return $this->removeFilePath($f, $removeItem);
     }
     return $this->removeFileItem($f, $removeItem);
 }