ListAliasesCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 23 3
A configure() 0 5 1
1
<?php
2
3
namespace Geekish\Crap\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Class ListAliasesCommand
10
 * @package Geekish\Crap\Command
11
 */
12
final class ListAliasesCommand extends BaseCommand
13
{
14
    /**
15
     * @inheritDoc
16
     */
17
    protected function configure()
18
    {
19
        $this->setName('aliases');
20
        $this->setDescription('List currently defined aliases');
21
    }
22
23
    /**
24
     * @inheritDoc
25
     * @codeCoverageIgnore
26
     */
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $aliases = $this->helper->getAliases();
30
31
        if (count($aliases) > 0) {
32
            $pad = max(array_map('strlen', $aliases)) + 3;
33
34
            foreach ($aliases as $alias) {
35
                $package = $this->helper->getAlias($alias);
36
                $output->writeln(sprintf(
37
                    '<comment>%s</comment> %s',
38
                    str_pad($alias, $pad, ' '),
39
                    $package
40
                ));
41
            }
42
43
            return 0;
44
        }
45
46
        $output->writeln('<comment>No aliases defined.</comment>');
47
48
        return 0;
49
    }
50
}
51