public function getConnection(string $name = null): Connection
    {
        if (is_null($name) and !is_null($this->defaultConnection)) {
            return $this->defaultConnection;
        }

        if (is_null($name) or !array_key_exists($name, $this->registry)) {
            throw new MongoDBConnectionNameNotFoundException($name);
        }

        return $this->registry[$name];
    }