Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a4d011c7dd | ||
|
0445ac3562 |
|
@ -5,6 +5,7 @@ namespace Amp\Sql;
|
|||
abstract class ConnectionConfig
|
||||
{
|
||||
const KEY_MAP = [
|
||||
'hostname' => 'host',
|
||||
'username' => 'user',
|
||||
'pass' => 'password',
|
||||
'database' => 'db',
|
||||
|
@ -32,7 +33,7 @@ abstract class ConnectionConfig
|
|||
* @param string $connectionString
|
||||
* @param string[] $keymap Map of alternative key names to canonical key names.
|
||||
*
|
||||
* @return array
|
||||
* @return string[]
|
||||
*/
|
||||
protected static function parseConnectionString(string $connectionString, array $keymap = self::KEY_MAP): array
|
||||
{
|
||||
|
@ -54,6 +55,11 @@ abstract class ConnectionConfig
|
|||
$values[$key] = $value;
|
||||
}
|
||||
|
||||
if (\preg_match('/^(.+):(\d{1,5})$/', $values["host"] ?? "", $matches)) {
|
||||
$values["host"] = $matches[1];
|
||||
$values["port"] = $matches[2];
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ interface Connector
|
|||
/**
|
||||
* @param ConnectionConfig $config
|
||||
*
|
||||
* @return Promise<Connection>
|
||||
* @return Promise<Link>
|
||||
*/
|
||||
public function connect(ConnectionConfig $config): Promise;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user