Test Setup Failed
Pull Request — master (#28)
by Anton
02:28
created

RunCommand::configure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 8.8571
cc 1
eloc 16
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/bluzman
5
 */
6
7
namespace Bluzman\Command;
8
9
use Application\CliBootstrap;
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputOption;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * Class List command
17
 *
18
 * @package Bluzman\Command
19
 *
20
 * @author   Pavel Machekhin
21
 * @created  2013-03-28 14:03
22
 */
23
class RunCommand extends AbstractCommand
24
{
25
    /**
26
     * Command configuration
27 14
     */
28
    protected function configure()
29
    {
30
        $this
31 14
            // the name of the command (the part after "bin/bluzman")
32
            ->setName('run')
33 14
            // the short description shown while running "php bin/bluzman list"
34
            ->setDescription('Run controller')
35
            // the full command description shown when running the command with
36 14
            // the "--help" option
37
            ->setHelp('Run specified controller with options params')
38
        ;
39 14
40 14
        $uri = new InputArgument(
41 14
            'uri',
42 14
            InputArgument::REQUIRED,
43
            'URI to call'
44
        );
45 14
46 14
        $this->getDefinition()->addArgument($uri);
47
48
49
        $debug = new InputOption(
50
            '--debug',
51
            '-d',
52
            InputOption::VALUE_NONE,
53
            'Display debug information'
54
        );
55
56
        $this->getDefinition()->addOption($debug);
57
    }
58
59
    /**
60
     * @param InputInterface $input
61
     * @param OutputInterface $output
62
     * @return int|null|void
63
     */
64
    protected function execute(InputInterface $input, OutputInterface $output)
65
    {
66
        if ($input->getOption('debug')) {
67
            error_reporting(E_ALL);
68
            ini_set('display_errors', 1);
69
        }
70
        $app = CliBootstrap::getInstance();
71
        $app->setInput($input);
72
        $app->setOutput($output);
73
        $app->init($input->getOption('env'));
74
        $app->run();
75
    }
76
}
77