Passed
Push — master ( cd6f4c...25aa03 )
by Adam
02:48
created

InstallCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
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 <[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 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...
33
{
34
	/**
35
	 * @return void
36
	 */
37
	protected function configure() : void
38
	{
39
		$this
40
			->setName('ipub:packages:install')
41
			->addArgument('package', Input\InputArgument::REQUIRED, 'Package name')
42
			->setDescription('Install 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->install($input->getArgument('package'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('package') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, IPub\Packages\IPackagesManager::install() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
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