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();
    }
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();
    }
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 ( ) ; }
Add a new endpoint to the list of endpoints
if the endpoint is already in the list, it will not be added again
as a side-effect, this method will modify _currentEndpointIndex

@param string $endpoint - the endpoint to add

@return void
Add a new endpoint to the list of endpoints if the endpoint is already in the list it will not be added again as a side - effect this method will modify _currentEndpointIndex