public function connectionString()
    {
        if (empty($this->username) || empty($this->password)) {
            return sprintf(
                "mongodb://%s:%d/%s",
                $this->host,
                $this->port,
                $this->db
            );
        }
        return sprintf(
            "mongodb://%s:%s@%s:%d/%s",
            $this->username,
            $this->password,
            $this->host,
            $this->port,
            $this->db
        );
    }