protected function getConnectionString($hosts, $protocol, $port)
    {
        // Normalize hosts into an array.
        $hosts = is_array($hosts) ? $hosts : [$hosts];

        $hosts = array_map(function ($host) use ($protocol, $port) {
            return "{$protocol}{$host}:{$port}";
        }, $hosts);

        return implode(' ', $hosts);
    }