drivers[$alias] = $driver; return $this; } public function connect(array $config): Connection { if (!isset($config['type'])) { throw new ConnectionException('type is not defined'); } $type = $config['type']; if (isset($this->drivers[$type])) { return $this->drivers[$type]($config); } throw new ConnectionException('unrecognised type'); } }