Advertisement
Guest User

cmyers

a guest
Sep 3rd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. class MyClass {
  2.     public function __call($name, $args) {
  3.  
  4.         switch ($name) {
  5.             case 'funcOne':
  6.                 switch (count($args)) {
  7.                     case 1:
  8.                         return call_user_func_array(array($this, 'funcOneWithOneArg'), $args);
  9.                     case 3:
  10.                         return call_user_func_array(array($this, 'funcOneWithThreeArgs'), $args);
  11.                  }
  12.             case 'anotherFunc':
  13.                 switch (count($args)) {
  14.                     case 0:
  15.                         return $this->anotherFuncWithNoArgs();
  16.                     case 5:
  17.                         return call_user_func_array(array($this, 'anotherFuncWithMoreArgs'), $args);
  18.                 }
  19.         }
  20.     }
  21.  
  22.     protected function funcOneWithOneArg($a) {
  23.  
  24.     }
  25.  
  26.     protected function funcOneWithThreeArgs($a, $b, $c) {
  27.  
  28.     }
  29.  
  30.     protected function anotherFuncWithNoArgs() {
  31.  
  32.     }
  33.  
  34.     protected function anotherFuncWithMoreArgs($a, $b, $c, $d, $e) {
  35.  
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement