From d34b80e30d5d5beed552e78935ed2869ffcab3bc Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 22 Mar 2014 15:23:37 +0000 Subject: [PATCH] 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 --- cli.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/cli.php b/cli.php index c9b5bb1..c13d5f5 100644 --- a/cli.php +++ b/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; }