protected function toUrlArray($data)
    {
        $url = array_intersect_key($data, $this->uriKeys);

        foreach (['host', 'user', 'pass'] as $key) {
            if (!isset($url[$key])) {
                continue;
            }

            $url[$key] = urlencode($url[$key]);
        }

        if ($url['adapter']) {
            $return = $url['scheme'] . '+' . $url['adapter'] . '://';
        } else {
            $return = $url['scheme'] . '://';
        }

        if (!empty($url['user'])) {
            $return .= $url['user'];
            if (!empty($url['pass'])) {
                $return .= ':' . $url['pass'];
            }
            $return .= '@';
        }

        $return .= $url['host'];

        $defaultPort = $this->defaultPort();
        if (!empty($url['port']) && $url['port'] != $defaultPort) {
            $return .= ':' . $url['port'];
        }
        $return .= $url['path'];

        $query = array_diff_key($data, $this->uriKeys);
        if ($query) {
            foreach ($query as $key => &$value) {
                if (is_array($value)) {
                    $intermediate = [];
                    foreach ($value as $k => $v) {
                        $v = urlencode($v);
                        $intermediate[] = "{$key}[$k]=$v";
                    }
                    $value = implode($intermediate, '&');

                    continue;
                }
                $value = "$key=$value";
            }
            $return .= '?' . implode($query, '&');
        }

        return $return;
    }