@@ -53,6 +53,10 @@ abstract class WSConnectorAbstract implements ConnectorInterface
53
53
*/
54
54
protected $ maxNumberOfTriesToCallApi = 3 ;
55
55
56
+ /**
57
+ * list of connectors by connector name
58
+ * @var Client[]
59
+ */
56
60
protected static $ connection ;
57
61
protected static $ currentId ;
58
62
@@ -150,11 +154,14 @@ public function orderNodesByTimeout($orderNodesByTimeout)
150
154
*/
151
155
public function getConnection ()
152
156
{
153
- if (self ::$ connection === null ) {
157
+ if (
158
+ !isset (self ::$ connection [static ::class])
159
+ || self ::$ connection [static ::class] === null
160
+ ) {
154
161
$ this ->newConnection ($ this ->getCurrentUrl ());
155
162
}
156
163
157
- return self ::$ connection ;
164
+ return self ::$ connection[ static ::class] ;
158
165
}
159
166
160
167
/**
@@ -164,17 +171,17 @@ public function getConnection()
164
171
*/
165
172
public function newConnection ($ nodeUrl )
166
173
{
167
- self ::$ connection = new Client ($ nodeUrl , ['timeout ' => $ this ->wsTimeoutSeconds ]);
174
+ self ::$ connection[ static ::class] = new Client ($ nodeUrl , ['timeout ' => $ this ->wsTimeoutSeconds ]);
168
175
169
- return self ::$ connection ;
176
+ return self ::$ connection[ static ::class] ;
170
177
}
171
178
172
179
public function getCurrentUrl ()
173
180
{
174
181
if (
175
- !isset (static ::$ currentNodeURL [$ this -> getPlatform () ])
176
- || static ::$ currentNodeURL [$ this -> getPlatform () ] === null
177
- || !in_array (static ::$ currentNodeURL [$ this -> getPlatform () ], static ::$ nodeURL )
182
+ !isset (static ::$ currentNodeURL [static ::class ])
183
+ || static ::$ currentNodeURL [static ::class ] === null
184
+ || !in_array (static ::$ currentNodeURL [static ::class ], static ::$ nodeURL )
178
185
) {
179
186
if (is_array (static ::$ nodeURL )) {
180
187
$ this ->reserveNodeUrlList = static ::$ nodeURL ;
@@ -183,10 +190,10 @@ public function getCurrentUrl()
183
190
$ url = static ::$ nodeURL ;
184
191
}
185
192
186
- static ::$ currentNodeURL [$ this -> getPlatform () ] = $ url ;
193
+ static ::$ currentNodeURL [static ::class ] = $ url ;
187
194
}
188
195
189
- return static ::$ currentNodeURL [$ this -> getPlatform () ];
196
+ return static ::$ currentNodeURL [static ::class ];
190
197
}
191
198
192
199
public function isExistReserveNodeUrl ()
@@ -196,7 +203,7 @@ public function isExistReserveNodeUrl()
196
203
197
204
protected function setReserveNodeUrlToCurrentUrl ()
198
205
{
199
- static ::$ currentNodeURL [$ this -> getPlatform () ] = array_shift ($ this ->reserveNodeUrlList );
206
+ static ::$ currentNodeURL [static ::class ] = array_shift ($ this ->reserveNodeUrlList );
200
207
}
201
208
202
209
public function connectToReserveNode ()
@@ -211,11 +218,14 @@ public function connectToReserveNode()
211
218
212
219
public function getCurrentId ()
213
220
{
214
- if (self ::$ currentId === null ) {
215
- self ::$ currentId = 1 ;
221
+ if (
222
+ !isset (self ::$ currentId [static ::class])
223
+ || self ::$ currentId [static ::class] === null
224
+ ) {
225
+ self ::$ currentId [static ::class] = 1 ;
216
226
}
217
227
218
- return self ::$ currentId ;
228
+ return self ::$ currentId[ static ::class] ;
219
229
}
220
230
221
231
public function getPlatform ()
@@ -225,7 +235,7 @@ public function getPlatform()
225
235
226
236
public function setCurrentId ($ id )
227
237
{
228
- self ::$ currentId = $ id ;
238
+ self ::$ currentId[ static ::class] = $ id ;
229
239
}
230
240
231
241
public function getNextId ()
0 commit comments