/** * Actually perform the connection * * @param ConnectionInterface $connection Connection * @param array $server Server (with `host`, `options', `port`, and `password`) */ private function doConnect(ConnectionInterface $connection, array $server) { $server += ['options' => []]; $connection->connect($server['options']); if (!empty($server['password'])) { $authCommand = new Auth(); $authCommand->setArguments([$server['password']]); $response = $authCommand->parse($connection->execute($authCommand)); if ($response !== 'OK') { throw new AuthenticationException(); } } }