Passed
Push — master ( 6791f9...01e57e )
by Adam
02:08
created

InstallCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 31
loc 31
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 7 7 1
A execute() 11 11 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * InstallCommand.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec https://www.ipublikuj.eu
8
 * @package        iPublikuj:Packages!
9
 * @subpackage     Commands
10
 * @since          2.0.0
11
 *
12
 * @date           19.07.16
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Packages\Commands;
18
19
use Symfony\Component\Console\Input;
20
use Symfony\Component\Console\Output;
21
22
use IPub\Packages\DependencyResolver;
23
use IPub\Packages\Exceptions;
24
25
/**
26
 * Package install command
27
 *
28
 * @package        iPublikuj:Packages!
29
 * @subpackage     Commands
30
 *
31
 * @author         Adam Kadlec <[email protected]>
32
 */
33 1 View Code Duplication
final class InstallCommand extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
{
35
	/**
36
	 * @return void
37
	 */
38
	protected function configure() : void
39
	{
40
		$this
41
			->setName('ipub:packages:install')
42
			->addArgument('package', Input\InputArgument::REQUIRED, 'Package name')
43
			->setDescription('Install package.');
44
	}
45
46
	/**
47
	 * @param Input\InputInterface $input
48
	 * @param Output\OutputInterface $output
49
	 * 
50
	 * @return void
51
	 */
52
	protected function execute(Input\InputInterface $input, Output\OutputInterface $output) : void
53
	{
54
		try {
55
			$this->packageManager->install($input->getArgument('package'));
56
57
			$output->writeln(sprintf('Package \'%s\' has been installed.', $input->getArgument('package')));
58
59
		} catch (Exceptions\InvalidArgumentException $e) {
60
			$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
61
		}
62
	}
63
}
64