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