@return \Neoxygen\NeoClient\Connection\Connection The default Connection if defined, the first connection in the connections array otherwise

@throws \Neoxygen\NeoClient\Exception\InvalidConnectionException If no connections are configured
554781
public function getDefaultConnection()
    {
        if (!$this->defaultConnection && empty($this->connections)) {
            throw new InvalidConnectionException('There are no connections configured');
        }

        if (!$this->defaultConnection) {
            reset($this->connections);

            return current($this->connections);
        }

        return $this->getConnection($this->defaultConnection);
    }
773375
public static function connection($name = 'default')
    {
        $name = $name == 'default' ? self::$config['connection']['default'] : $name;

        return isset(self::$connection[$name])
            ? self::$connection[$name]
            : self::$connection[$name] = self::createForConnection($name);
    }
201622
public function connection($connection = null)
    {
        $connection = $connection ?: $this->getDefaultConnection();

        if (is_null($connection)) {
            throw new \InvalidArgumentException(sprintf('Unable to resolve NULL connection for [%s].', get_called_class()));
        }

        // If the given connection has not been created before, we will create the instances
        // here and cache it so we can return it next time very quickly. If there is
        // already a connection created by this name, we'll just return that instance.
        if (! isset($this->connections[$connection])) {
            $this->connections[$connection] = $this->createConnection($connection);
        }

        return $this->connections[$connection];
    }
455729
public function getDefault()
    {
        // get the memoized default
        if ($this->default) {
            return $this->get($this->default);
        }

        // no configurations available
        // check for existing connections
        if (0 === count($this->config)) {
            if (1 === count($this->connections)) {
                $this->default = array_keys($this->connections)[0];

                return $this->get($this->default);
            } elseif (count($this->connections) > 1) {
                throw new JAQBException('Could not determine the default connection because multiple connections were available and the default has not been set.');
            }

            throw new JAQBException('The default connection is not available because no configurations have been supplied.');
        }

        // handle the case where there is a single configuration
        if (1 === count($this->config)) {
            $this->default = array_keys($this->config)[0];

            return $this->get($this->default);
        }

        // handle multiple configurations
        foreach ($this->config as $k => $v) {
            if (array_value($v, 'default')) {
                $this->default = $k;

                return $this->get($this->default);
            }
        }

        throw new JAQBException('There is no default connection.');
    }
937621
public function getConnection($name = null)
    {
        if (null === $name) {
            $name = $this->defaultConnection;
        }

        if (!isset($this->connections[$name])) {
            throw new \InvalidArgumentException(sprintf('AMQP Connection named "%s" does not exist.', $name));
        }

        return $this->connections[$name];
    }
121661
public function getConnection()
	{
		if ($this->_connection === null) {
			if (!isset(Yii::$app->redis)) {
				throw new InvalidConfigException(get_class($this)." expects a 'redis' application component");
			}
			$this->_connection = Yii::$app->redis;
		}
		return $this->_connection;
	}
158560
protected function connection()
	{
		if (empty($this->connection))
		{
			$this->connection = new \SoapClient($this->resource, $this->options);
		}

		return $this->connection;
	}
538214
protected function openConnection()
    {
        $this->response = null;
        $this->httpStatus = null;

        if (!$this->connection = curl_init()) {
            throw new ConnectionErrorException('Unable to open connection');
        }

        $this->setConnectionOptions($this->connectionOptions);
        return $this;
    }
440079
public function chosen() : ?Connection
    {
        foreach ($this->loaders as $loader) {
            $confObj = $loader->chosen();

            if ($confObj !== null) {
                return $confObj;
            }
        }

        return null;
    }
1280786
protected function _connection() {
		if ($this->_connection) {
			return $this->_connection;
		}
		$host = "{$this->_config['protocol']}://{$this->_config['host']}";

		if ($this->_connection = fsockopen($host, $this->_config['port'], $message, $code)) {
			return $this->_connection;
		}
		throw new NetworkException("Growl connection failed: (`{$code}`) `{$message}`.");
	}
998579
public function getConnection() {
        if (null === $this->connection) {
            $this->connection = $this->connect();
        }
        return $this->connection;
    }
588682
public function getSlaveConnection()
    {
        if (null === $this->slaveConnection) {
            $this->slaveConnection = new \Redis();
            $this->slaveConnection->pconnect(
                $this->config['slave']['HOST'],
                $this->config['slave']['PORT']
            );
        }
        return $this->slaveConnection;
    }
32035
public function getConnection()
    {
        if ($this->connection) {
            return $this->connection;
        }

        return $this->connection = new SFTP($this->host, $this->port, $this->timeout);
    }
89844
public static function getConnection($connectionName = '')
    {
        if (!$connectionName) {
            $connectionName = static::$defaultConnection;
        }
        if (isset(static::$connections[$connectionName])) {
            return static::$connections[$connectionName];
        }
    }
364007
public function getConnection()
    {
        if ($this->connection instanceof ConnectionInterface === FALSE)
        {
            $this->connection = Propel::getConnection();
        }

        return $this->connection;
    }
482998
public function getConnection()
    {
        $connection = parent::getConnection();

        if ( ! app()->bound(Component::CORE)) {
            // @codeCoverageIgnoreStart
            return $connection;
            // @codeCoverageIgnoreEnd
        }

        /** @var CoreInterface $core */
        $core = app(Component::CORE);
        $cmsConnection = $core->config('database.driver');

        // If no separate database driver is configured for the CMS,
        // we can use the normal driver and rely on the prefix alone.
        if ( ! $cmsConnection) {
            return $connection;
        }

        // If we're running tests, make sure we use the correct override
        // for the CMS database connection/driver.
        // N.B. This is ignored on purpose if the default connection is not overridden normally.
        if (app()->runningUnitTests()) {
            $cmsConnection = $core->config('database.testing.driver') ?: $cmsConnection;
        }

        return $cmsConnection;
    }
955788
private function connection() {
      $this->apply_config_db();
      try {
         if ( @$_ENV["daniia_connection"] && !$this->id_conn ) {
            $this->id_conn = $_ENV["daniia_connection"];
         }
         elseif ( !$this->id_conn ) {
            $this->id_conn = new \PDO($this->dsn, $this->user, $this->pass);
         }
      } catch (\PDOException $e) {
         die("Error: " . $e->getMessage() . "<br/>");
      }

      $this->get_instance();
      return $this;
   }