/** * @param InputInterface $input * @param OutputInterface $output * @return integer|NULL */ protected function execute(InputInterface $input, OutputInterface $output) { $finder = (new Finder())->files()->name($this::IMAGES)->in($folder = getcwd()); $progress = new ProgressIterator($output, $finder); $progress->onSingleStep[] = function ($bar, $file) use($input, $folder) { $bar->setMessage(str_replace($folder, '.', $file)); if (!$this->resizeImage($input, $file)) { // Failed conversion } $bar->advance(); }; $progress->execute(); }
/** * @param InputInterface $input * @param OutputInterface $output * @return integer|NULL */ protected function execute(InputInterface $input, OutputInterface $output) { $finder = (new Finder())->files()->name($this::IMAGES)->in($folder = getcwd()); $progress = new ProgressIterator($output, $finder); $progress->onSingleStep[] = function ($bar, $file) use($input, $folder) { $bar->setMessage(str_replace($folder, '.', $file)); $path = $file->getPathname(); if (!rename($path, rtrim($path, '.backup'))) { // Restore has failed } $bar->advance(); }; $progress->execute(); }
/** * @param InputInterface $input * @param OutputInterface $output * @return integer|NULL */ protected function execute(InputInterface $input, OutputInterface $output) { $finder = (new Finder())->in($folder = getcwd())->exclude('vendor')->exclude('bin'); if (!($rules = $this->loadRules())) { return 0; } $progress = new ProgressIterator($output, $finder); $progress->onSingleStep[] = function ($bar, $file) use($rules, $folder) { $bar->setMessage(str_replace($folder, '.', $file)); foreach ($rules as $rule) { $rule->apply($file); } $bar->advance(); }; $progress->execute(); }