UpdateCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 29.73 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 5
dl 11
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 11 17 4

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
 * For the full copyright and license information, please view the LICENSE.md
4
 * file that was distributed with this source code.
5
 */
6
7
namespace Notamedia\ConsoleJedi\Module\Command;
8
9
use Notamedia\ConsoleJedi\Application\CanRestartTrait;
10
use Notamedia\ConsoleJedi\Module\Module;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputOption;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * Command for module installation/register
17
 *
18
 * @author Marat Shamshutdinov <[email protected]>
19
 */
20
class UpdateCommand extends ModuleCommand
21
{
22
	use CanRestartTrait;
23
24
	/**
25
	 * {@inheritdoc}
26
	 */
27
	protected function configure()
28
	{
29
		parent::configure();
30
31
		$this->setName('module:update')
32
			->setDescription('Load module updates from Marketplace')
33
			->addOption('beta', 'b', InputOption::VALUE_NONE, 'Allow the installation of beta releases');
34
	}
35
36
	/**
37
	 * {@inheritdoc}
38
	 */
39
	protected function execute(InputInterface $input, OutputInterface $output)
40
	{
41
		$module = new Module($input->getArgument('module'));
42
		$modulesUpdated = null;
43 View Code Duplication
		while ($module->update($modulesUpdated))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
44
		{
45
			if (is_array($modulesUpdated))
46
			{
47
				foreach ($modulesUpdated as $moduleName => $moduleVersion)
48
				{
49
					$output->writeln(sprintf('updated %s to <info>%s</info>', $moduleName, $moduleVersion));
50
				}
51
			}
52
			return $this->restartScript($input, $output);
53
		}
54
		return 0;
55
	}
56
}