Skip to content

Commit daf511c

Browse files
author
Igor Paramonov
committed
[sns] replaced custom parsing by dsn
1 parent 74ea369 commit daf511c

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

pkg/sns/SnsConnectionFactory.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,10 @@ private function parseDsn(string $dsn): array
136136
'version' => $dsn->getString('version'),
137137
'lazy' => $dsn->getBool('lazy'),
138138
'endpoint' => $dsn->getString('endpoint'),
139-
'topic_arns' => $this->extractTopicArns($dsn->getString('topic_arns')),
139+
'topic_arns' => $dsn->getArray('topic_arns', [])->toArray(),
140140
]), function ($value) { return null !== $value; });
141141
}
142142

143-
private function extractTopicArns(?string $topicArns): array
144-
{
145-
if (!$topicArns) {
146-
return [];
147-
}
148-
149-
return array_column(
150-
array_map(function ($topic) {
151-
list($name, $arn) = explode('|', $topic);
152-
153-
return [
154-
'name' => $name,
155-
'arn' => $arn,
156-
];
157-
}, explode(';', $topicArns)),
158-
'arn',
159-
'name'
160-
);
161-
}
162-
163143
private function defaultConfig(): array
164144
{
165145
return [

pkg/sns/Tests/SnsConnectionFactoryConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static function provideConfigs()
159159
];
160160

161161
yield [
162-
['dsn' => 'sns:?topic_arns=topic1|arn:aws:sns:us-east-1:123456789012:topic1;topic2|arn:aws:sns:us-west-2:123456789012:topic2'],
162+
['dsn' => 'sns:?topic_arns[topic1]=arn:aws:sns:us-east-1:123456789012:topic1&topic_arns[topic2]=arn:aws:sns:us-west-2:123456789012:topic2'],
163163
[
164164
'key' => null,
165165
'secret' => null,

0 commit comments

Comments
 (0)