Skip to content

Commit 8106cef

Browse files
authored
Merge DSN settings into existing config
1 parent 115653f commit 8106cef

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pkg/sqs/SqsConnectionFactory.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ public function __construct($config = 'sqs:')
3939
{
4040
if (empty($config) || 'sqs:' === $config) {
4141
$config = [];
42-
}
43-
44-
if (is_string($config)) {
42+
} elseif (is_string($config)) {
4543
$config = $this->parseDsn($config);
46-
}
44+
} elseif (is_array($config)) {
45+
$dsn = array_key_exists('dsn', $config) ? $config['dsn'] : null;
46+
unset($config['dsn']);
4747

48-
if (!is_array($config)) {
49-
throw new \LogicException('The config must be either an array of options, a DSN string, or null');
50-
}
51-
52-
if (count($config) == 1 && array_key_exists('dsn', $config)) {
53-
$config = $this->parseDsn($config['dsn']);
48+
if ($dsn) {
49+
$config = array_replace($config, $this->parseDsn($dsn));
50+
}
51+
} else {
52+
throw new \LogicException('The config must be either an array of options, a DSN string or null');
5453
}
5554

5655
$this->config = array_replace($this->defaultConfig(), $config);

0 commit comments

Comments
 (0)