Qa\SoftMocks::call PHP Method

call() public static method

Generic method to call a callable, useful for proxying call_user_func* calls
public static call ( $callable, $args ) : mixed
$callable
$args
return mixed
    public static function call($callable, $args)
    {
        if (is_scalar($callable) && strpos($callable, '::') === false) {
            return self::callFunction('', $callable, $args);
        }
        if (is_scalar($callable)) {
            $parts = explode('::', $callable);
            if (count($parts) != 2) {
                throw new \RuntimeException("Invalid callable format for '{$callable}', expected single '::'");
            }
            list($obj, $method) = $parts;
        } else {
            if (is_array($callable)) {
                if (count($callable) != 2) {
                    throw new \RuntimeException("Invalid callable format, expected array of exactly 2 elements");
                }
                list($obj, $method) = $callable;
            } else {
                return call_user_func_array($callable, $args);
            }
        }
        if (is_object($obj)) {
            return self::callMethod($obj, null, $method, $args, true);
        } else {
            if (is_scalar($obj)) {
                return self::callStaticMethod($obj, $method, $args, true);
            }
        }
        throw new \RuntimeException("Invalid callable format, expected first array element to be object or scalar, " . gettype($obj) . " given");
    }