ServiceCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 62
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 9 2
A configure() 0 10 1
1
<?php
2
3
namespace Acacha\Llum\Console;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Input\InputOption;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class ServiceCommand.
11
 */
12
class ServiceCommand extends LlumCommand
13
{
14
    /**
15
     * Command name.
16
     *
17
     * @var string
18
     */
19
    protected $commandName = 'service';
20
21
    /**
22
     * Command description.
23
     *
24
     * @var string
25
     */
26
    protected $commandDescription = 'add service or services from file to config/services.php file';
27
28
    /**
29
     * Command argument.
30
     *
31
     * @var string
32
     */
33
    protected $argument = 'file';
34
35
    /**
36
     * Command argument description.
37
     *
38
     * @var string
39
     */
40
    protected $argumentDescription = 'the file with service/services to add';
41
42
    /**
43
     * Execute the command.
44
     *
45
     * @param InputInterface  $input
46
     * @param OutputInterface $output
47
     *
48
     * @return int|null|void
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $this->output = $output;
53
        $outputFile = null;
54
        if ($file = $input->getOption('output-file')) {
55
            $outputFile = $file;
56
        }
57
        $this->service($input->getArgument($this->argument), $outputFile);
58
    }
59
60
    /**
61
     * Configure the command options.
62
     */
63
    protected function configure()
64
    {
65
        parent::configure();
66
        $this->addOption(
67
            'output-file',
68
            'o',
69
            InputOption::VALUE_REQUIRED,
70
            'If set, config/services.php will not be changed and only shows result on standard output'
71
        );
72
    }
73
}
74