<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ include 'Request.php'; //include 'AdminActions.php'; $request = new Request(); $class = $request->getGroup() . 'Actions'; require_once $class . '.php'; $cmd = $request->getCommand(); $action = new $class(); $action->{$cmd}($request);
private function handle($command) { $request = new Request($command); $response = new Response(); $name = $request->getName(); if (!empty($name)) { if ($this->hasCommand($name)) { $command = $this->getCommand($name); $handler = $command->getHandler(); call_user_func_array($handler, [$request, $response]); } else { $command = $request->getCommand(); passthru($command); $response->line(); //echo "command '{$name}' not found\n"; } } }
/** * @dataProvider cliCommandProvider * * @param array $cliArguments * @param string $expectedCommand */ public function testReturnsExpectedCommand(array $cliArguments, $expectedCommand) { $request = new Request($cliArguments); $this->assertSame($expectedCommand, $request->getCommand()); }