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

RunCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B configure() 0 30 1
A execute() 0 12 2
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