fastdlabs /
fastD
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @author jan huang <[email protected]> |
||
| 4 | * @copyright 2016 |
||
| 5 | * |
||
| 6 | * @see https://www.github.com/janhuang |
||
| 7 | * @see https://fastdlabs.com |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace FastD; |
||
| 11 | |||
| 12 | use Symfony\Component\Console\Input\ArgvInput; |
||
| 13 | use Symfony\Component\Console\Input\InputInterface; |
||
| 14 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Class Client. |
||
| 18 | */ |
||
| 19 | class Client extends Console |
||
| 20 | { |
||
| 21 | public function __construct(Application $app) |
||
| 22 | { |
||
| 23 | parent::__construct($app); |
||
| 24 | |||
| 25 | $this->add(new \FastD\Console\Client()); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param InputInterface|null $input |
||
| 30 | * @param OutputInterface|null $output |
||
| 31 | * |
||
| 32 | * @return int |
||
| 33 | * |
||
| 34 | * @throws \Exception |
||
| 35 | */ |
||
| 36 | public function run(InputInterface $input = null, OutputInterface $output = null) |
||
|
0 ignored issues
–
show
|
|||
| 37 | { |
||
| 38 | $argv = $_SERVER['argv']; |
||
| 39 | $script = array_shift($argv); |
||
| 40 | array_unshift($argv, 'client'); |
||
| 41 | array_unshift($argv, $script); |
||
| 42 | |||
| 43 | return parent::run(new ArgvInput($argv), $output); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: