ServiceCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
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