UpdateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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
}