public static function fromDSN($dsn, $timeout = 0, $verifySSL = false)
{
$connParams = parse_url($dsn);
$schemeInfo = explode('+', $connParams['scheme']);
$dbName = null;
$modifier = null;
$scheme = $schemeInfo[0];
if (isset($schemeInfo[1])) {
$modifier = strtolower($schemeInfo[0]);
$scheme = $schemeInfo[1];
}
if ($scheme != 'influxdb') {
throw new ClientException($scheme . ' is not a valid scheme');
}
$ssl = $modifier === 'https' ? true : false;
$dbName = $connParams['path'] ? substr($connParams['path'], 1) : null;
$client = new self($connParams['host'], $connParams['port'], isset($connParams['user']) ? $connParams['user'] : '', isset($connParams['pass']) ? $connParams['pass'] : '', $ssl, $verifySSL, $timeout);
// set the UDP driver when the DSN specifies UDP
if ($modifier == 'udp') {
$client->setDriver(new UDP($connParams['host'], $connParams['port']));
}
return $dbName ? $client->selectDB($dbName) : $client;
}