public static function encodeQueryString(array $query, $rfc = self::RFC_3986)
    {
        $ret = [];
        $encode = self::getQueryStringEncoder($rfc);
        foreach ($query as $name => $value) {
            if (is_array($value)) {
                foreach ($value as $v) {
                    $ret[] = $name.'='.$encode($v);
                }
            }
            else {
                $ret[] = $name.'='.$encode($value);
            }
        }
        return implode('&', $ret);
    }