registry = $registry; $that->defaultConnectionName = $connectionName; return $that; } private function __construct() { } public function getConnection(?string $name = null): Connection { $connection = $this->registry->getConnection($name ?? $this->defaultConnectionName); if (! $connection instanceof Connection) { throw InvalidConfiguration::invalidConnectionType($connection); } return $connection; } }