private function connect(array &$connections)
    {
        $exceptions = [];
        while (count($connections) > 0) {
            /** @var Connection $connection */
            $connection = array_pop($connections);

            try {
                if ($connection->open()) {
                    return $connection;
                }
            } catch (DatabaseException $e) {
                $exceptions[] = $e->getMessage();
            }
        }

        throw new ConnectionException(
            'Unable to select connection.',
            '',
            0,
            count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
        );
    }
private function connect(array &$connections)
    {
        $exceptions = [];
        while (count($connections) > 0) {
            /** @var Connection $connection */
            $connection = array_pop($connections);

            try {
                if ($connection->open()) {
                    return $connection;
                }
            } catch (DatabaseException $e) {
                $exceptions[] = $e->getMessage();
            }
        }

        throw new ConnectionException(
            'Unable to select connection.',
            '',
            0,
            count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
        );
    }
private function connect ( array & $ connections ) { $ exceptions = [ ] ; while ( count ( $ connections ) > 0 ) { /** @var Connection $connection */ $ connection = array_pop ( $ connections ) ; try { if ( $ connection -> open ( ) ) { return $ connection ; } } catch ( DatabaseException $ e ) { $ exceptions [ ] = $ e -> getMessage ( ) ; } } throw new ConnectionException ( 'Unable to select connection.' , '' , 0 , count ( $ exceptions ) > 0 ? new ConnectionException ( implode ( ' ' , $ exceptions ) ) : null ) ; }
Calls the connect method for every connection in the given array and returns the connection on success.

@param Connection[] $connections

@throws ConnectionException

@return Connection
Calls the connect method for every connection in the given array and returns the connection on success .