InfoCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 4
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 19 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
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