lithium\core\Object::invokeMethod PHP Method

invokeMethod() public method

Calls a method on this object with the given parameters. Provides an OO wrapper for call_user_func_array, and improves performance by using straight method calls in most cases.
public invokeMethod ( string $method, array $params = [] ) : mixed
$method string Name of the method to call
$params array Parameter list to use when calling $method
return mixed Returns the result of the method call
    public function invokeMethod($method, $params = array())
    {
        switch (count($params)) {
            case 0:
                return $this->{$method}();
            case 1:
                return $this->{$method}($params[0]);
            case 2:
                return $this->{$method}($params[0], $params[1]);
            case 3:
                return $this->{$method}($params[0], $params[1], $params[2]);
            case 4:
                return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
            case 5:
                return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
            default:
                return call_user_func_array(array(&$this, $method), $params);
        }
    }