Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 protected function getResultState(InputInterface $input, OutputInterface $output, Report $report)
 {
     $isVerbose = $output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG;
     if ($report->count() === 0) {
         $output->writeln('<info>✔ Looking good</info>');
         return 0;
     }
     $output->writeln('');
     foreach ($report as $message) {
         $output->write('<info>');
         $output->writeln('file    : ' . $message->getFile()->getPath() . ':' . $message->getLine());
         $output->writeln('tool    : ' . $message->getTool()->getName());
         if ($isVerbose) {
             $output->writeln('info    : ' . $message->getTool()->getDescription());
         }
         $output->writeln('message : ' . $message->getText());
         $output->writeln('</info>');
     }
     if ($input->getOption('save')) {
         $output->writeln('<info>✔ Fixed</info>');
     } else {
         $output->writeln('<comment>✔ Dry run</comment>');
     }
     return 0;
 }
Ejemplo n.º 2
0
 /**
  * @param FilesCollection $files
  * @param Report $report
  */
 public function process(FilesCollection $files, Report $report)
 {
     $isDebug = $this->getOutput()->isDebug();
     foreach ($files as $file) {
         $errorsNum = $report->count();
         if ($isDebug) {
             $this->getOutput()->writeln('⚑ open  : ' . $file->getPath());
         }
         foreach ($this->getTools() as $tool) {
             if (!$tool->canProcess($file)) {
                 continue;
             }
             $tool->process($file, $report);
             if ($errorsNum === $report->count()) {
                 if ($isDebug) {
                     $this->getOutput()->writeln('✔ ok    : ' . $tool->getDescription() . ' (' . $tool->getName() . ')');
                 }
                 continue;
             }
             $this->getOutput()->writeln('✘ error : ' . $tool->getDescription() . ' (' . $tool->getName() . ')');
         }
     }
 }