Completed
Push — master ( 6d20cc...f05bcc )
by T
10:20
created

BaseCommand::initialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 6
1
<?php
2
3
namespace PHPSemVerChecker\Console\Command;
4
5
use PHPSemVerChecker\Configuration\Configuration;
6
use PHPSemVerChecker\Configuration\LevelMapping;
7
use PHPSemVerChecker\Console\InputMerger;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class BaseCommand extends Command
13
{
14
	/**
15
	 * @var \PHPSemVerChecker\Configuration\Configuration
16
	 */
17
	protected $config;
18
19
	/**
20
	 * @param \Symfony\Component\Console\Input\InputInterface   $input
21
	 * @param \Symfony\Component\Console\Output\OutputInterface $output
22
	 */
23
	protected function initialize(InputInterface $input, OutputInterface $output)
24
	{
25
		parent::initialize($input, $output);
26
		$configPath = $input->getOption('config');
27
		$this->config = $configPath ? Configuration::fromFile($configPath) : Configuration::defaults('php-semver-checker');
28
		$inputMerger = new InputMerger();
29
		$inputMerger->merge($input, $this->config);
30
31
		// Set overrides
32
		LevelMapping::setOverrides($this->config->getLevelMapping());
33
	}
34
}
35