AliasCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 2
cbo 3
dl 0
loc 86
ccs 49
cts 49
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 49 1
A execute() 0 5 1
A getTask() 0 5 1
1
<?php
2
namespace Samurai\Alias;
3
4
use Samurai\Alias\Task\Factory\AliasManagementTaskFactory;
5
use Samurai\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class AliasCommand
13
 * @package Samurai\Project
14
 * @author Raphaël Lefebvre <[email protected]>
15
 */
16
class AliasCommand extends Command
17
{
18
19
    /**
20
     * @var array
21
     */
22
    public static $actions = [
23
        'save',
24
        'list',
25
        'rm'
26
    ];
27
28
    /**
29
     *
30
     */
31 15
    protected function configure()
32 1
    {
33 15
        $this
34 15
            ->setName('alias')
35 15
            ->setDescription('Handles bootstrap alias')
36 15
            ->addArgument(
37 15
                'action',
38 15
                InputArgument::OPTIONAL,
39 15
                'sub-command: ' . json_encode(self::$actions)
40 15
            )
41 15
            ->addArgument(
42 15
                'name',
43 15
                InputArgument::OPTIONAL,
44
                'alias name'
45 15
            )
46 15
            ->addArgument(
47 15
                'bootstrap',
48 15
                InputArgument::OPTIONAL,
49
                'package name'
50 15
            )
51 15
            ->addArgument(
52 15
                'version',
53 15
                InputArgument::OPTIONAL,
54
                'package version'
55 15
            )
56 15
            ->addArgument(
57 15
                'description',
58 15
                InputArgument::OPTIONAL,
59
                'bootstrap description'
60 15
            )
61 15
            ->addArgument(
62 15
                'source',
63 15
                InputArgument::OPTIONAL,
64
                'bootstrap source'
65 15
            )
66 15
            ->addOption(
67 15
                'global',
68 15
                'g',
69 15
                InputOption::VALUE_NONE,
70
                'Display global alias'
71 15
            )
72 15
            ->addOption(
73 15
                'local',
74 15
                'l',
75 15
                InputOption::VALUE_NONE,
76
                'Display local alias'
77 15
            )
78 15
            ->setHelp('See the documentation for more info: https://github.com/Raphhh/samurai');
79 15
    }
80
81
    /**
82
     * @param InputInterface $input
83
     * @param OutputInterface $output
84
     * @return void
85
     */
86 6
    protected function execute(InputInterface $input, OutputInterface $output)
87
    {
88 6
        $this->getTask($input)->execute($input, $output);
89 6
        $this->getService('alias_manager')->flush();
90 6
    }
91
92
    /**
93
     * @param InputInterface $input
94
     * @return \Samurai\Task\ITask
95
     */
96 6
    private function getTask(InputInterface $input)
97
    {
98 6
        $factory = new AliasManagementTaskFactory();
99 6
        return $factory->create($input, $this->getServices());
100
    }
101
}
102
103