public function addEndpoint($endpoint) 
    {
        if (!is_string($endpoint) || !Endpoint::isValid($endpoint)) {
            throw new ClientException(sprintf("invalid endpoint specification '%s'", $endpoint));
        }
        $endpoint = Endpoint::normalize($endpoint);
        $normalized = Endpoint::normalizeHostname($endpoint);

        assert(is_array($this->_values[self::OPTION_ENDPOINT]));
        $found = false;
        foreach ($this->_values[self::OPTION_ENDPOINT] as $key => $value) {
            if ($normalized === Endpoint::normalizeHostname($value)) {
                $this->_currentEndpointIndex = $key;
                $found = true;
                break;
            }
        }
        
        if ($found === false) {
            // a new endpoint we have not seen before
            $this->_values[self::OPTION_ENDPOINT][] = $endpoint;
            $this->_currentEndpointIndex = count($this->_values[self::OPTION_ENDPOINT]) - 1;
        }

        $this->storeOptionsInCache();
    }