/**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $startTime = microtime(true);
     $finder = new Finder();
     $scannerBefore = new Scanner();
     $scannerAfter = new Scanner();
     $sourceBefore = $this->config->get('source-before');
     $includeBefore = $this->config->get('include-before');
     $excludeBefore = $this->config->get('exclude-before');
     $sourceAfter = $this->config->get('source-after');
     $includeAfter = $this->config->get('include-after');
     $excludeAfter = $this->config->get('exclude-after');
     $sourceBefore = $finder->findFromString($sourceBefore, $includeBefore, $excludeBefore);
     $sourceAfter = $finder->findFromString($sourceAfter, $includeAfter, $excludeAfter);
     $sourceFilter = new SourceFilter();
     $identicalCount = $sourceFilter->filter($sourceBefore, $sourceAfter);
     $progress = new ProgressScanner($output);
     $progress->addJob($this->config->get('source-before'), $sourceBefore, $scannerBefore);
     $progress->addJob($this->config->get('source-after'), $sourceAfter, $scannerAfter);
     $progress->runJobs();
     $registryBefore = $scannerBefore->getRegistry();
     $registryAfter = $scannerAfter->getRegistry();
     $analyzer = new Analyzer();
     $report = $analyzer->analyze($registryBefore, $registryAfter);
     $reporter = new Reporter($report);
     $reporter->setFullPath($this->config->get('full-path'));
     $reporter->output($output);
     $toJson = $this->config->get('to-json');
     if ($toJson) {
         $jsonReporter = new JsonReporter($report, $toJson);
         $jsonReporter->output();
     }
     $duration = microtime(true) - $startTime;
     $output->writeln('');
     $output->writeln('[Scanned files] Before: ' . count($sourceBefore) . ', After: ' . count($sourceAfter) . ', Identical: ' . $identicalCount);
     $output->writeln('Time: ' . round($duration, 3) . ' seconds, Memory: ' . round(memory_get_peak_usage() / 1024 / 1024, 3) . ' MB');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $startTime = microtime(true);
     $targetDirectory = getcwd();
     $commitBefore = $input->getArgument('before');
     $commitAfter = $input->getArgument('after');
     $includeBefore = $input->getOption('include-before');
     $excludeBefore = $input->getOption('exclude-before');
     $includeAfter = $input->getOption('include-after');
     $excludeAfter = $input->getOption('exclude-after');
     $finder = new Finder();
     $sourceFilter = new SourceFilter();
     $beforeScanner = new Scanner();
     $afterScanner = new Scanner();
     $client = new Client();
     $repository = $client->getRepository($targetDirectory);
     $modifiedFiles = $repository->getModifiedFiles($commitBefore, $commitAfter);
     $modifiedFiles = array_filter($modifiedFiles, function ($modifiedFile) {
         return substr($modifiedFile, -4) === '.php';
     });
     $initialBranch = $repository->getCurrentBranch();
     $repository->checkout($commitBefore . ' --');
     $sourceBefore = $finder->findFromString($targetDirectory, $includeBefore, $excludeBefore);
     $sourceBeforeMatchedCount = count($sourceBefore);
     $sourceBefore = $sourceFilter->filter($sourceBefore, $modifiedFiles);
     $progress = new ProgressBar($output, count($sourceBefore));
     foreach ($sourceBefore as $file) {
         $beforeScanner->scan($file);
         $progress->advance();
     }
     $progress->clear();
     $repository->checkout($commitAfter . ' --');
     $sourceAfter = $finder->findFromString($targetDirectory, $includeAfter, $excludeAfter);
     $sourceAfterMatchedCount = count($sourceAfter);
     $sourceAfter = $sourceFilter->filter($sourceAfter, $modifiedFiles);
     $progress = new ProgressBar($output, count($sourceAfter));
     foreach ($sourceAfter as $file) {
         $afterScanner->scan($file);
         $progress->advance();
     }
     $progress->clear();
     if ($initialBranch) {
         $repository->checkout($initialBranch);
     }
     $progress->clear();
     $registryBefore = $beforeScanner->getRegistry();
     $registryAfter = $afterScanner->getRegistry();
     $analyzer = new Analyzer();
     $report = $analyzer->analyze($registryBefore, $registryAfter);
     $reporter = new Reporter($report);
     $reporter->setFullPath(true);
     $reporter->output($output);
     $toJson = $input->getOption('to-json');
     if ($toJson) {
         $commitBeforeHash = $repository->getCommit($commitBefore)->getHash();
         $commitAfterHash = $repository->getCommit($commitAfter)->getHash();
         $jsonReporter = new JsonReporter($report, $toJson, $commitBeforeHash, $commitAfterHash);
         $jsonReporter->output();
     }
     $duration = microtime(true) - $startTime;
     $output->writeln('');
     $output->writeln('[Scanned files] Before: ' . count($sourceBefore) . ' (' . $sourceBeforeMatchedCount . ' unfiltered), After: ' . count($sourceAfter) . ' (' . $sourceAfterMatchedCount . ' unfiltered)');
     $output->writeln('Time: ' . round($duration, 3) . ' seconds, Memory: ' . round(memory_get_peak_usage() / 1024 / 1024, 3) . ' MB');
 }