@@ -60,6 +60,9 @@ public function __construct($config = 'sns:')
6060
6161 unset($ config ['dsn ' ]);
6262 }
63+ if (\array_key_exists ('topic_arns ' , $ config ) && \is_string ($ config ['topic_arns ' ])) {
64+ $ config ['topic_arns ' ] = $ this ->extractTopicArns ($ config ['topic_arns ' ]);
65+ }
6366 } else {
6467 throw new \LogicException (\sprintf ('The config must be either an array of options, a DSN string, null or instance of %s ' , AwsSnsClient::class));
6568 }
@@ -133,12 +136,30 @@ private function parseDsn(string $dsn): array
133136 'version ' => $ dsn ->getString ('version ' ),
134137 'lazy ' => $ dsn ->getBool ('lazy ' ),
135138 'endpoint ' => $ dsn ->getString ('endpoint ' ),
136- 'topic_arns ' => ($ topicArns = $ dsn ->getString ('topic_arns ' ))
137- ? array_filter (explode (', ' , $ topicArns ))
138- : [],
139+ 'topic_arns ' => $ this ->extractTopicArns ($ dsn ->getString ('topic_arns ' )),
139140 ]), function ($ value ) { return null !== $ value ; });
140141 }
141142
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+
142163 private function defaultConfig (): array
143164 {
144165 return [
0 commit comments