public static function appendUrlQuery($url, $query)
    {
        if (is_array($query)) {
            $query = http_build_query($query);
        }
        $query  = ltrim($query, "?&");
        $joiner = strpos($url, "?") === false ? "?" : "&";
        
        return "{$url}{$joiner}{$query}";
    }