$connection) { $this->addConnection($name, $connection); } } /** * Get a database connection instance. */ public function connection(?string $name = null): ConnectionInterface { if (is_null($name)) { $name = $this->getDefaultConnection(); } return $this->connections[$name]; } /** * Add a connection to the resolver. * * @param string $name */ public function addConnection($name, ConnectionInterface $connection) { $this->connections[$name] = $connection; } /** * Check if a connection has been registered. * * @param string $name */ public function hasConnection($name): bool { return isset($this->connections[$name]); } /** * Get the default connection name. */ public function getDefaultConnection(): string { return $this->default; } /** * Set the default connection name. */ public function setDefaultConnection(string $name): void { $this->default = $name; } }