Completed
Pull Request — master (#30)
by Anton
17:34
created

RunCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 61.53%

Importance

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

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
     */
28 14
    protected function configure()
29
    {
30
        $this
31
            // the name of the command (the part after "bin/bluzman")
32 14
            ->setName('run')
33
            // the short description shown while running "php bin/bluzman list"
34 14
            ->setDescription('Run controller')
35
            // the full command description shown when running the command with
36
            // the "--help" option
37 14
            ->setHelp('Run specified controller with options params')
38
        ;
39
40 14
        $uri = new InputArgument(
41 14
            'uri',
42 14
            InputArgument::REQUIRED,
43 14
            'URI to call'
44
        );
45
46 14
        $this->getDefinition()->addArgument($uri);
47
48
49 14
        $debug = new InputOption(
50 14
            '--debug',
51 14
            '-d',
52 14
            InputOption::VALUE_NONE,
53 14
            'Display debug information'
54
        );
55
56 14
        $this->getDefinition()->addOption($debug);
57 14
    }
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