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

InstallCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
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