Get a remote connection instance.

@param string|array|mixed $name

@return \Collective\Remote\ConnectionInterface
769333
public function into($name)
    {
        if (is_string($name) || is_array($name)) {
            return $this->connection($name);
        } else {
            return $this->connection(func_get_args());
        }
    }
1087889
public function connection(?string $name = null): self
    {
        $this->connection = $name ? $name : $this->app->make('config')->get('microservice-client.connection');

        return $this;
    }
752096
public function get($name)
    {
        $name = ltrim($name, '\\');
        if (! isset($this->instances[$name])) {
            $this->instances[$name] = $this->newInstance($name);
        }
        return $this->instances[$name];
    }
964738
public function getService($name)
    {
        if (array_key_exists($name, $this->services)) {
            return $this->services[$name];
        } elseif (isset($this->serviceProviders[$name]) && $this->serviceProviders[$name] instanceof ServiceProviderInterface) {
            $service = $this->serviceProviders[$name]->instantiate();
            if (!empty($this->serviceConfiguration[$name]['persistent'])) {
                $this->setService($name, $service);
            }
            return $service;
        } else {
            throw new Exception("Requested service {$name} is not registered");
        }
    }
1183810
private static function getConnectionConfiguration($name)
    {
        $databaseConfig = Configuration::get('database.connections');
        if (isset($databaseConfig[$name])) {
            $databaseConfig = $databaseConfig[$name];
        } else {
            $databaseConfig = null;
        }

        if ($databaseConfig === null) {
            throw new ConfigurationException("Database configuration for connection '" . $name . "' doesn't exists!");
        }

        if (! isset($databaseConfig['driver'])) {
            throw new ConfigurationException("Database configuration for connection '" . $name . "' is invalid!");
        }

        return $databaseConfig;
    }
1363648
public function getAdapter($name)
    {
        if (!isset($this->adapters[$name])) {
            throw new Exception\ConnectionException(
                "Adapter " . $name . " not registered on connection!"
            );
        }

        return $this->adapters[$name];
    }
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);
    }
1251032
public function getConnection($name = ''): QueryBuilderInterface
	{
		// If the parameter is a string, use it as an array index
		if (is_scalar($name) && isset($this->connections[$name]))
		{
			return $this->connections[$name];
		}
		else if (empty($name) && ! empty($this->connections)) // Otherwise, return the last one
		{
			return end($this->connections);
		}

		// You should actually connect before trying to get a connection...
		throw new InvalidArgumentException('The specified connection does not exist');
	}
1047963
protected function configuration($name)
    {
        $name = $name ?: $this->getDefaultConnection();

        // To get the database connection configuration, we will just pull each of the
        // connection configurations and get the configurations for the given name.
        // If the configuration doesn't exist, we'll throw an exception and bail.
        $connections = $this->container['config']['database.connections']->toArray();

        if (is_null($config = Arr::get($connections, $name))) {
            throw new InvalidArgumentException("Database [$name] not configured.");
        }

        return $config;
    }
348976
public static function get($name)
    {
        if (!isset(self::$connections[$name])) {
            throw new Exception(sprintf('Connection "%s" does not exist.', $name));
        }

        return self::$connections[$name];
    }
1166910
public function getConnectionConfig($name)
    {
        $name = $name ?: $this->default;

        if (!is_array($config = Arr::get($this->config, $name)) && !$config) {
            throw new InvalidArgumentException("Connection [$name] not configured.");
        }

        return $config;
    }
542559
protected function getConfig( $name )
	{
		$name = $name ?: $this->getDefaultConnection();

		// To get the database connection configuration, we will just pull each of the
		// connection configurations and get the configurations for the given name.
		// If the configuration doesn't exist, we'll throw an exception and bail.
		$connections = Framework::config()->get( 'database.connections' );

		if ( is_null( $config = Arr::get( $connections, $name ) ) )
			throw new InvalidArgumentException( "Database [$name] not configured." );

		return $config;
	}
55618
public function getConnection($name = null)
    {
        $this->serviceContext = static::CONNECTION_CONTEXT;
        $result = parent::getConnection($name);
        $this->serviceContext = null;
        return $result;
    }
472717
public function getConnection(string $name=null, array $params=[])
  {
    # Find the connection - null if it's not created
    $connection = $this->findConnection($name);

    if (\is_null($connection)) {
      # Create the connection
      $connection = $this->createConnection($name, $params);

      if (!\is_null($connection)) {
        $this->addConnection($connection);
      }
    }

    return $connection;
  }
1340216
public function getConnection($name)
    {
        if (!$this->connectionSettings->has($name)) {
            throw new BadArgumentException('Connection with name ":name" not defined in configuration file ":file"', [
                'name' => $name, 'file' => ServiceLocator::instance()->getConfiguration()->getIdentity(),
            ]);
        }
        
        if (!static::$connections->has($name)) {
            static::$connections->set($name, new Connection($this->connectionSettings->get($name)));
        }
        
        return static::$connections[$name];
    }
409580
public function getAdminConnection($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultConnectionName();
        }

        $serviceName = sprintf('doctrine_phpcr.admin.%s_session', $name);

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

        return $this->getService($serviceName);
    }
356555
public function get($name)
    {
        // get from cache
        if (isset($this->pool[$name])) {
            return $this->pool[$name];
        }
        
        // check if connection exists
        if (!isset($this->configuration[$name])) {
            throw new Exception('Connection with name ' . $name . ' not found');
        }
        
        // check if dsn exists
        if (!isset($this->configuration[$name]['dsn'])) {
            $this->configuration[$name]['dsn'] = null;
        }
        
        // check if connect options exists
        if (empty($this->configuration[$name]['connectOptions'])) {
            $this->configuration[$name]['connectOptions'] = null;
        }
        
        // init client
        $client = new Client(
            $this->configuration[$name]['dsn'],
            $this->configuration[$name]['connectOptions']
        );
        
        if (isset($this->configuration[$name]['mapping'])) {
            $client->map($this->configuration[$name]['mapping']);
        }
        
        if (isset($this->configuration[$name]['defaultDatabase'])) {
            $client->useDatabase($this->configuration[$name]['defaultDatabase']);
        }
        
        $this->pool[$name] = $client;
        
        return $client;
    }