/** * @param string $target * @param Version $version * * @return ExecuteResult */ public function execute($target, Version $version) { $filesystem = new Filesystem(); if ($this->io && !$this->io->isVerbose()) { $this->output(sprintf('Removing: <comment>0%%</comment>')); } $collection = new FileCollection($this->cwd); if (!$this->options['files'] && $this->options['exclude']) { $collection->add('*'); } foreach ($this->options['files'] as $file) { $collection->add($file); } foreach ($this->options['exclude'] as $file) { $collection->remove($file); } $files = $collection->toArray(); $total = count($files); $i = 0; foreach ($files as $file) { $filename = sprintf('%s/%s', rtrim($this->cwd, DIRECTORY_SEPARATOR), $file); $filesystem->remove($filename); if ($this->io && !$this->io->isVerbose()) { $this->output(sprintf('Removing: <comment>%d%%</comment>', round(++$i * 100 / $total))); } else { $this->output(sprintf("Removed %s", $file)); } // remove empty directories $this->removeEmptyDirectories($this->cwd, $file); } if ($this->io && !$this->io->isVerbose()) { $this->output(sprintf('Removing: <comment>%d%%</comment>', 100)); } return new ExecuteResult(array(), $files); }