ModuleCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 2
cbo 3
dl 0
loc 78
ccs 37
cts 37
cp 1
rs 10

3 Methods

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