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

InputMerger   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 5
c 2
b 0
f 2
lcom 0
cbo 2
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B merge() 0 18 5
1
<?php
2
3
namespace PHPSemVerChecker\Console;
4
5
use PHPSemVerChecker\Configuration\Configuration;
6
use Symfony\Component\Console\Input\InputInterface;
7
8
/**
9
 * Merges CLI input with existing configuration values.
10
 *
11
 * This is to ensure that CLI input has priority and is prepared for validation
12
 * by symfony/console commands.
13
 */
14
class InputMerger
15
{
16
	/**
17
	 * @param \Symfony\Component\Console\Input\InputInterface $input
18
	 * @param \PHPSemVerChecker\Configuration\Configuration $config
19
	 */
20 1
	public function merge(InputInterface $input, Configuration $config)
21
	{
22 1
		foreach ($input->getArguments() as $argument => $value) {
23 1
			if ($input->hasArgumentSet($argument)) {
0 ignored issues
show
Bug introduced by
The method hasArgumentSet() does not exist on Symfony\Component\Console\Input\InputInterface. Did you maybe mean hasArgument()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
24 1
				$config->set($argument, $value);
25 1
			} else {
26 1
				$input->setArgument($argument, $config->get($argument));
27
			}
28 1
		}
29
30 1
		foreach ($input->getOptions() as $option => $value) {
31 1
			if ($input->hasOptionSet($option)) {
0 ignored issues
show
Bug introduced by
The method hasOptionSet() does not exist on Symfony\Component\Console\Input\InputInterface. Did you maybe mean hasOption()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
32 1
				$config->set($option, $value);
33 1
			} else {
34 1
				$input->setOption($option, $config->get($option));
35
			}
36 1
		}
37 1
	}
38
}
39