public static function callFunction($namespace, $func, $params)
{
if ($namespace !== '' && is_scalar($func)) {
$ns_func = $namespace . '\\' . $func;
if (isset(self::$func_mocks[$ns_func])) {
if (self::$debug) {
self::debug("Intercepting call to {$ns_func}");
}
if (self::$func_mocks[$ns_func]['code'] instanceof \Closure) {
$func_callable = self::$func_mocks[$ns_func]['code'];
} else {
$func_callable = eval("return function(" . self::$func_mocks[$ns_func]['args'] . ") use (\$params) { " . self::$func_mocks[$ns_func]['code'] . " };");
}
return call_user_func_array($func_callable, $params);
}
if (is_callable($ns_func)) {
return call_user_func_array($ns_func, $params);
}
}
if (is_scalar($func)) {
if (isset(self::$func_mocks[$func])) {
if (self::$debug) {
self::debug("Intercepting call to {$func}");
}
if (self::$func_mocks[$func]['code'] instanceof \Closure) {
$func_callable = self::$func_mocks[$func]['code'];
} else {
$func_callable = eval("return function(" . self::$func_mocks[$func]['args'] . ") use (\$params) { " . self::$func_mocks[$func]['code'] . " };");
}
return call_user_func_array($func_callable, $params);
}
}
return call_user_func_array($func, $params);
}