protected function getConnection(string $type, Server $server) : IConnection
    {
        switch ($type) {
            case 'master':
                if ($this->servers['master']['server'] == null) {
                    throw new RuntimeException('No master specified');
                }

                if ($this->servers['master']['connection'] == null) {
                    $this->servers['master']['connection'] = $this->connectToServer($server);
                }

                return $this->servers['master']['connection'];
            default:
                $serverHashId = spl_object_hash($server);

                if (!isset($this->servers[$type][$serverHashId])
                    || $this->servers[$type][$serverHashId]['server'] == null
                ) {
                    throw new RuntimeException("Server of type '" . $type . "' not added to connection pool");
                }

                if ($this->servers[$type][$serverHashId]['connection'] == null) {
                    $this->servers[$type][$serverHashId]['connection'] = $this->connectToServer($server);
                }

                return $this->servers[$type][$serverHashId]['connection'];
        }
    }
protected function getConnection(string $type, Server $server) : IConnection
    {
        switch ($type) {
            case 'master':
                if ($this->servers['master']['server'] == null) {
                    throw new RuntimeException('No master specified');
                }

                if ($this->servers['master']['connection'] == null) {
                    $this->servers['master']['connection'] = $this->connectToServer($server);
                }

                return $this->servers['master']['connection'];
            default:
                $serverHashId = spl_object_hash($server);

                if (!isset($this->servers[$type][$serverHashId])
                    || $this->servers[$type][$serverHashId]['server'] == null
                ) {
                    throw new RuntimeException("Server of type '" . $type . "' not added to connection pool");
                }

                if ($this->servers[$type][$serverHashId]['connection'] == null) {
                    $this->servers[$type][$serverHashId]['connection'] = $this->connectToServer($server);
                }

                return $this->servers[$type][$serverHashId]['connection'];
        }
    }
protected function getConnection ( string $ type , Server $ server ) : IConnection { switch ( $ type ) { case 'master' : if ( $ this -> servers [ 'master' ] [ 'server' ] == null ) { throw new RuntimeException ( 'No master specified' ) ; } if ( $ this -> servers [ 'master' ] [ 'connection' ] == null ) { $ this -> servers [ 'master' ] [ 'connection' ] = $ this -> connectToServer ( $ server ) ; } return $ this -> servers [ 'master' ] [ 'connection' ] ; default : $ serverHashId = spl_object_hash ( $ server ) ; if ( ! isset ( $ this -> servers [ $ type ] [ $ serverHashId ] ) || $ this -> servers [ $ type ] [ $ serverHashId ] [ 'server' ] == null ) { throw new RuntimeException ( "Server of type '" . $ type . "' not added to connection pool" ) ; } if ( $ this -> servers [ $ type ] [ $ serverHashId ] [ 'connection' ] == null ) { $ this -> servers [ $ type ] [ $ serverHashId ] [ 'connection' ] = $ this -> connectToServer ( $ server ) ; } return $ this -> servers [ $ type ] [ $ serverHashId ] [ 'connection' ] ; } }
Gets a connection to the input server

@param string $type The type of server we're trying to connect to, eg "master", "custom"
@param Server $server The server we want to connect to
@return IConnection The connection to the server
@throws RuntimeException Thrown if the connection pool wasn't configured correctly
Gets a connection to the input server