Skip to content

Commit fa5084f

Browse files
committed
Move config to field in CompareCommand
1 parent b384760 commit fa5084f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/PHPSemVerChecker/Console/Command/CompareCommand.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
use Symfony\Component\Console\Output\OutputInterface;
2020

2121
class CompareCommand extends Command {
22+
/**
23+
* @var Configuration
24+
*/
25+
protected $config;
26+
2227
protected function configure()
2328
{
2429
$this
@@ -42,24 +47,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
4247
$startTime = microtime(true);
4348

4449
$configPath = $input->getOption('config');
45-
$configuration = $configPath ? Configuration::fromFile($configPath) : Configuration::defaults();
50+
$this->config = $configPath ? Configuration::fromFile($configPath) : Configuration::defaults();
4651
$im = new InputMerger();
47-
$im->merge($input, $configuration);
52+
$im->merge($input, $this->config);
4853

4954
// Set overrides
50-
LevelMapping::setOverrides($configuration->getLevelMapping());
55+
LevelMapping::setOverrides($this->config->getLevelMapping());
5156

5257
$finder = new Finder();
5358
$scannerBefore = new Scanner();
5459
$scannerAfter = new Scanner();
5560

56-
$sourceBefore = $configuration->get('source-before');
57-
$includeBefore = $configuration->get('include-before');
58-
$excludeBefore = $configuration->get('exclude-before');
61+
$sourceBefore = $this->config->get('source-before');
62+
$includeBefore = $this->config->get('include-before');
63+
$excludeBefore = $this->config->get('exclude-before');
5964

60-
$sourceAfter = $configuration->get('source-after');
61-
$includeAfter = $configuration->get('include-after');
62-
$excludeAfter = $configuration->get('exclude-after');
65+
$sourceAfter = $this->config->get('source-after');
66+
$includeAfter = $this->config->get('include-after');
67+
$excludeAfter = $this->config->get('exclude-after');
6368

6469
$sourceBefore = $finder->findFromString($sourceBefore, $includeBefore, $excludeBefore);
6570
$sourceAfter = $finder->findFromString($sourceAfter, $includeAfter, $excludeAfter);
@@ -68,8 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6873
$identicalCount = $sourceFilter->filter($sourceBefore, $sourceAfter);
6974

7075
$progress = new ProgressScanner($output);
71-
$progress->addJob($configuration->get('source-before'), $sourceBefore, $scannerBefore);
72-
$progress->addJob($configuration->get('source-after'), $sourceAfter, $scannerAfter);
76+
$progress->addJob($this->config->get('source-before'), $sourceBefore, $scannerBefore);
77+
$progress->addJob($this->config->get('source-after'), $sourceAfter, $scannerAfter);
7378
$progress->runJobs();
7479

7580
$registryBefore = $scannerBefore->getRegistry();
@@ -79,10 +84,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
7984
$report = $analyzer->analyze($registryBefore, $registryAfter);
8085

8186
$reporter = new Reporter($report);
82-
$reporter->setFullPath($configuration->get('full-path'));
87+
$reporter->setFullPath($this->config->get('full-path'));
8388
$reporter->output($output);
8489

85-
$toJson = $configuration->get('to-json');
90+
$toJson = $this->config->get('to-json');
8691
if ($toJson) {
8792
$jsonReporter = new JsonReporter($report, $toJson);
8893
$jsonReporter->output();

0 commit comments

Comments
 (0)