Simplify the cli.php by using call_user_func_array() to launch the method in the class
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1236 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
14
cli.php
14
cli.php
@@ -161,19 +161,7 @@ $cli->run(); */
|
||||
|
||||
// TODO : Manage a parameter in the constructor of the class
|
||||
$r = new $class;
|
||||
switch (count ($argv))
|
||||
{
|
||||
case 0: $s=$r->$method(); break;
|
||||
case 1: $s=$r->$method($argv[0]); break;
|
||||
case 2: $s=$r->$method($argv[0], $argv[1]); break;
|
||||
case 3: $s=$r->$method($argv[0], $argv[1], $argv[2]); break;
|
||||
case 4: $s=$r->$method($argv[0], $argv[1], $argv[2], $argv[3]); break;
|
||||
case 5: $s=$r->$method($argv[0], $argv[1], $argv[2], $argv[3], $argv[4]);
|
||||
break;
|
||||
default:
|
||||
die ("Too much parameter on the method to be used in CLI\n");
|
||||
}
|
||||
|
||||
$s = call_user_func_array(array($r, $method), $argv);
|
||||
var_dump ($s);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user