Completed
Push — master ( 7af315...01acd0 )
by Hannah
11:56
created

InfoCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 19
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 2
1
<?php
2
3
namespace Geekish\Crap\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class UnaliasCommand
11
 * @package Geekish\Crap\Command
12
 */
13 View Code Duplication
final class InfoCommand extends BaseCommand
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...
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    protected function configure()
19
    {
20
        $this->setName("info");
21
        $this->setDescription("Get a single alias.");
22
        $this->addArgument("alias", InputArgument::REQUIRED, "Package alias");
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $alias = $input->getArgument("alias");
31
32
        if (!$this->helper->hasAlias($alias)) {
33
            $output->writeln(sprintf(
34
                "<success>Alias `%s` does not exist.</success>",
35
                $alias
36
            ));
37
38
            return 1;
39
        }
40
41
        $package = $this->helper->getAlias($alias);
42
43
        $output->writeln(sprintf("Alias `%s` is set to: <comment>%s</comment>", $alias, $package));
44
45
        return 0;
46
    }
47
}
48