Run::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
/**
3
 * Part of Cli for CodeIgniter
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2015 Kenji Suzuki
8
 * @link       https://github.com/kenjis/codeigniter-cli
9
 */
10
11
namespace Kenjis\CodeIgniter_Cli\Command;
12
13
use Aura\Cli\Status;
14
15
class Run extends Command
16
{
17
    public function __invoke($controller = null, $method = null)
18
    {
19
        if ($controller === null) {
20
            $this->stdio->errln('<<red>>Controller is needed<<reset>>');
21
            return Status::USAGE;
22
        }
23
24
        $argv = $this->context->argv->get();
25
        array_shift($argv);
26
        array_shift($argv);
27
        array_shift($argv);
28
        array_shift($argv);
29
        $arguments = implode(' ', $argv);
30
31
        $console = FCPATH . 'index.php';
32
        $this->stdio->outln(
33
            "<<green>>php {$console} {$controller} {$method} {$arguments}<<reset>>"
34
        );
35
        passthru("php {$console} {$controller} {$method}  {$arguments}");
36
        $this->stdio->outln('');
37
    }
38
}
39