UninstallCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 10%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 31
loc 31
ccs 1
cts 10
cp 0.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
 * UninstallCommand.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
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\Exceptions;
23
24
/**
25
 * Package install command
26
 *
27
 * @package        iPublikuj:Packages!
28
 * @subpackage     Commands
29
 *
30
 * @author         Adam Kadlec <[email protected]>
31
 */
32 1 View Code Duplication
final class UninstallCommand 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...
33
{
34
	/**
35
	 * @return void
36
	 */
37
	protected function configure() : void
38
	{
39
		$this
40
			->setName('ipub:packages:uninstall')
41
			->addArgument('package', Input\InputArgument::REQUIRED, 'Package name')
42
			->setDescription('Uninstall package.');
43
	}
44
45
	/**
46
	 * @param Input\InputInterface $input
47
	 * @param Output\OutputInterface $output
48
	 *
49
	 * @return void
50
	 */
51
	protected function execute(Input\InputInterface $input, Output\OutputInterface $output) : void
52
	{
53
		try {
54
			$this->packageManager->uninstall($input->getArgument('package'));
55
56
			$output->writeln(sprintf('Package \'%s\' has been installed.', $input->getArgument('package')));
57
58
		} catch (Exceptions\InvalidArgumentException $e) {
59
			$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
60
		}
61
	}
62
}
63