BaseCommand::initialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.9
c 0
b 0
f 0
cc 2
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
	 * @throws \Noodlehaus\Exception\EmptyDirectoryException
23
	 */
24
	protected function initialize(InputInterface $input, OutputInterface $output)
25
	{
26
		parent::initialize($input, $output);
27
		$configPath = $input->getOption('config');
28
		$this->config = $configPath ? Configuration::fromFile($configPath) : Configuration::defaults('php-semver-checker');
29
		$inputMerger = new InputMerger();
30
		$inputMerger->merge($input, $this->config);
31
32
		// Set overrides
33
		LevelMapping::setOverrides($this->config->getLevelMapping());
34
	}
35
}
36