protected static function _call($callable, $request, $params)
{
$params = compact('callable', 'request', 'params');
return static::_filter(__FUNCTION__, $params, function ($self, $params) {
if (is_callable($callable = $params['callable'])) {
$request = $params['request'];
$params = $params['params'];
if (!method_exists($callable, $params['action'])) {
array_unshift($params['args'], $request->params['action']);
$params['action'] = 'run';
}
$isHelp = !empty($params['help']) || !empty($params['h']) || !method_exists($callable, $params['action']);
if ($isHelp) {
$params['action'] = '_help';
}
return $callable($params['action'], $params['args']);
}
throw new UnexpectedValueException("Callable `{$callable}` is actually not callable.");
});
}