InfoCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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
final class InfoCommand extends BaseCommand
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