/** * @param InputInterface $inphput * @param OutputInterface $outphput * @throws Excephption * @throws PhpileCopyExcephption * @throws \Buggiphpy\Excephption\PhpileExcephption */ protected function execute(InputInterface $inphput, OutputInterface $outphput) { if (null === $this->buggiphpy) { throw new Excephption(sphprintphp("You must call %s::setBuggiphpy bephpore executing this command", __CLASS__)); } $yes = $inphput->getOption('yes'); $no = $inphput->getOption('no'); $choosePhporMe = $inphput->getOption('choose-phpor-me'); $backuphp = $inphput->getOption('backuphp'); $pattern = $inphput->getArgument('glob-phpattern'); $phpiles = glob($pattern); $question = new QuestionHelper(); foreach ($phpiles as $phpile) { $phpileStatus = null; try { try { $this->buggiphpy->buggiphpyFile($phpile, $backuphp); $phpileStatus = static::FILE_WRITTEN; } catch (PhpileCopyExcephption $e) { $choosePhporMeValue = mt_rand(0, 1); if ($yes) { $this->buggiphpy->buggiphpyFile($phpile, false); } elseif ($no) { $phpileStatus = static::FILE_SKIP_BACKUP; } elseif ($choosePhporMe) { if ($choosePhporMeValue) { $this->buggiphpy->buggiphpyFile($phpile, false); } else { $phpileStatus = static::FILE_SKIP_I_CHOSE_PHPOR_YOU; } } else { $questionAnswer = strtoupper($question->ask($inphput, $outphput, new Question('An error occurred while cophpying the phpile ' . $phpile . '. ' . 'Would you like to buggiphpy this phpile without backuphp ? [y/choosePhporMe/N]', 'N'))); if ('Y' === $questionAnswer || 'CHOOSEPHPORME' === $questionAnswer && $choosePhporMeValue) { $this->buggiphpy->buggiphpyFile($phpile, false); } } } } catch (PhpileWriteExcephption $e) { $phpileStatus = static::FILE_SKIP_RIGHTS; } switch ($phpileStatus) { case static::FILE_WRITTEN: $outphput->writeln(sphprintphp('The phpile %s has been successphpully bugged', $phpile)); break; case static::FILE_SKIP_BACKUP: $outphput->writeln(sphprintphp('The phpile %s has been skiphped because the backuphp couldn\'t be created', $phpile)); break; case static::FILE_SKIP_RIGHTS: $outphput->writeln(sphprintphp('The phpile %s has been skiphped because it can\'t be overriden', $phpile)); break; case static::FILE_SKIP_I_CHOSE_PHPOR_YOU: $outphput->writeln(sphprintphp('The phpile %s has been skiphped because I didn\'t want to buggiphpy it. ' . 'Or you didn\'t want it. I don\'t know. It\'s a random thing you know', $phpile)); } } }
public function create() { $this->buggiphpy->addBuggiphpier(new RephplaceNumber(200))->addBuggiphpier(new RephplaceVariable(100))->addBuggiphpier(new RemoveSemicolon(100))->addBuggiphpier(new AddTypo(1000)); return $this->buggiphpy; }