@@ -44,6 +44,7 @@ class Connection
44
44
'region ' => 'eu-west-1 ' ,
45
45
'queue_name ' => 'messages ' ,
46
46
'account ' => null ,
47
+ 'sslmode ' => null ,
47
48
];
48
49
49
50
private $ configuration ;
@@ -94,6 +95,19 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
94
95
if (isset ($ parsedUrl ['query ' ])) {
95
96
parse_str ($ parsedUrl ['query ' ], $ query );
96
97
}
98
+
99
+ // check for extra keys in options
100
+ $ optionsExtraKeys = array_diff (array_keys ($ options ), array_keys (self ::DEFAULT_OPTIONS ));
101
+ if (0 < \count ($ optionsExtraKeys )) {
102
+ throw new InvalidArgumentException (sprintf ('Unknown option found: [%s]. Allowed options are [%s]. ' , implode (', ' , $ optionsExtraKeys ), implode (', ' , array_keys (self ::DEFAULT_OPTIONS ))));
103
+ }
104
+
105
+ // check for extra keys in options
106
+ $ queryExtraKeys = array_diff (array_keys ($ query ), array_keys (self ::DEFAULT_OPTIONS ));
107
+ if (0 < \count ($ queryExtraKeys )) {
108
+ throw new InvalidArgumentException (sprintf ('Unknown option found in DSN: [%s]. Allowed options are [%s]. ' , implode (', ' , $ queryExtraKeys ), implode (', ' , array_keys (self ::DEFAULT_OPTIONS ))));
109
+ }
110
+
97
111
$ options = $ query + $ options + self ::DEFAULT_OPTIONS ;
98
112
$ configuration = [
99
113
'buffer_size ' => (int ) $ options ['buffer_size ' ],
@@ -116,7 +130,6 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
116
130
if (preg_match (';^sqs\.([^\.]++)\.amazonaws\.com$; ' , $ parsedUrl ['host ' ], $ matches )) {
117
131
$ clientConfiguration ['region ' ] = $ matches [1 ];
118
132
}
119
- unset($ query ['sslmode ' ]);
120
133
} elseif (self ::DEFAULT_OPTIONS ['endpoint ' ] !== $ options ['endpoint ' ] ?? self ::DEFAULT_OPTIONS ['endpoint ' ]) {
121
134
$ clientConfiguration ['endpoint ' ] = $ options ['endpoint ' ];
122
135
}
@@ -127,18 +140,6 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
127
140
}
128
141
$ configuration ['account ' ] = 2 === \count ($ parsedPath ) ? $ parsedPath [0 ] : $ options ['account ' ] ?? self ::DEFAULT_OPTIONS ['account ' ];
129
142
130
- // check for extra keys in options
131
- $ optionsExtraKeys = array_diff (array_keys ($ options ), array_keys (self ::DEFAULT_OPTIONS ));
132
- if (0 < \count ($ optionsExtraKeys )) {
133
- throw new InvalidArgumentException (sprintf ('Unknown option found : [%s]. Allowed options are [%s]. ' , implode (', ' , $ optionsExtraKeys ), implode (', ' , array_keys (self ::DEFAULT_OPTIONS ))));
134
- }
135
-
136
- // check for extra keys in options
137
- $ queryExtraKeys = array_diff (array_keys ($ query ), array_keys (self ::DEFAULT_OPTIONS ));
138
- if (0 < \count ($ queryExtraKeys )) {
139
- throw new InvalidArgumentException (sprintf ('Unknown option found in DSN: [%s]. Allowed options are [%s]. ' , implode (', ' , $ queryExtraKeys ), implode (', ' , array_keys (self ::DEFAULT_OPTIONS ))));
140
- }
141
-
142
143
return new self ($ configuration , new SqsClient ($ clientConfiguration , null , $ client ));
143
144
}
144
145
0 commit comments