Skip to content

Commit 11dc680

Browse files
authored
Merge pull request #315 from beryllium/patch-1
[Sqs] Allow array-based DSN configuration
2 parents 5fe96ea + a6b4ec0 commit 11dc680

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/sqs/SqsConnectionFactory.php

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public function __construct($config = 'sqs:')
4242
} elseif (is_string($config)) {
4343
$config = $this->parseDsn($config);
4444
} elseif (is_array($config)) {
45+
$dsn = array_key_exists('dsn', $config) ? $config['dsn'] : null;
46+
unset($config['dsn']);
47+
48+
if ($dsn) {
49+
$config = array_replace($config, $this->parseDsn($dsn));
50+
}
4551
} else {
4652
throw new \LogicException('The config must be either an array of options, a DSN string or null');
4753
}

pkg/sqs/Tests/SqsConnectionFactoryConfigTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ public static function provideConfigs()
104104
],
105105
];
106106

107+
yield [
108+
['dsn' => 'sqs:?key=theKey&secret=theSecret&token=theToken&lazy=0'],
109+
[
110+
'key' => 'theKey',
111+
'secret' => 'theSecret',
112+
'token' => 'theToken',
113+
'region' => null,
114+
'retries' => 3,
115+
'version' => '2012-11-05',
116+
'lazy' => false,
117+
],
118+
];
119+
107120
yield [
108121
['key' => 'theKey', 'secret' => 'theSecret', 'token' => 'theToken', 'lazy' => false],
109122
[

0 commit comments

Comments
 (0)