protected function call(string $method, array $params)
{
$func = $method;
// If an alias was given, use the actual method
if (isset($this->aliases[$method])) {
$func = $this->aliases[$method];
}
// Class method
if (false !== strpos($func, '::')) {
list($className, $methodName) = explode('::', $func);
try {
// Method exists
$reflection = new \ReflectionMethod($className, $methodName);
if ($reflection->isStatic()) {
// Method is static
$callback = [$className, $methodName];
} else {
// Method is not static
$callback = [new $className(), $methodName];
}
} catch (\ReflectionException $e) {
// Method does not exist
if (method_exists($className, '__call')) {
// Is __call available
$callback = [new $className(), $methodName];
} else {
// Is __callStatic available
$callback = [$className, $methodName];
}
}
} else {
// Simple function
$callback = $func;
}
$result = call_user_func_array($callback, $params);
// Logging
$this->log($method, $params, $result);
return $result;
}