LMongo\Connection::getDsn PHP Method

getDsn() protected method

Create a DSN string from a configuration.
protected getDsn ( array $config ) : string
$config array
return string
    protected function getDsn(array $config)
    {
        // First we will create the basic DSN setup as well as the port if it is in
        // in the configuration options. This will give us the basic DSN we will
        // need to establish the MongoClient and return them back for use.
        extract($config);
        $dsn = "mongodb://";
        if (isset($config['username']) and isset($config['password'])) {
            $dsn .= "{$username}:{$password}@";
        }
        $dsn .= "{$host}";
        if (isset($config['port'])) {
            $dsn .= ":{$port}";
        }
        $dsn .= "/{$database}";
        return $dsn;
    }