Conditions | 1 |
Paths | 1 |
Total Lines | 205 |
Code Lines | 130 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
130 | public function providerProcess(): array |
||
131 | { |
||
132 | return [ |
||
133 | 'normal' => [ |
||
134 | [ |
||
135 | 'uppTransactionId' => '123456789012345678', |
||
136 | 'status' => 'success', |
||
137 | 'refno' => '16001', |
||
138 | 'amount' => '1000', |
||
139 | 'currency' => 'CHF', |
||
140 | 'responseMessage' => 'Payment was successful', |
||
141 | 'sign' => 'c0a817ad85a2bc830f8fd9d4f1cd0f3a2a8757239f98ec1700a182e7f182c6a7', |
||
142 | ], |
||
143 | [ |
||
144 | 'message' => [ |
||
145 | 'status' => 'success', |
||
146 | 'message' => 'Payment was successful', |
||
147 | ], |
||
148 | ], |
||
149 | ], |
||
150 | 'invalid HMAC signature' => [ |
||
151 | [ |
||
152 | 'uppTransactionId' => '123456789012345678', |
||
153 | 'status' => 'success', |
||
154 | 'refno' => '16001', |
||
155 | 'amount' => '1000', |
||
156 | 'currency' => 'CHF', |
||
157 | 'responseMessage' => 'Payment was successful', |
||
158 | 'sign' => 'a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0', |
||
159 | ], |
||
160 | [ |
||
161 | 'message' => [ |
||
162 | 'status' => 'error', |
||
163 | 'message' => 'Invalid HMAC signature', |
||
164 | ], |
||
165 | ], |
||
166 | ], |
||
167 | 'missing HMAC signature' => [ |
||
168 | [ |
||
169 | 'uppTransactionId' => '123456789012345678', |
||
170 | 'status' => 'success', |
||
171 | 'refno' => '16001', |
||
172 | 'amount' => '1000', |
||
173 | 'currency' => 'CHF', |
||
174 | 'responseMessage' => 'Payment was successful', |
||
175 | ], |
||
176 | [ |
||
177 | 'message' => [ |
||
178 | 'status' => 'error', |
||
179 | 'message' => 'Missing HMAC signature', |
||
180 | ], |
||
181 | ], |
||
182 | ], |
||
183 | 'error' => [ |
||
184 | [ |
||
185 | 'uppTransactionId' => '876543210987654321', |
||
186 | 'status' => 'error', |
||
187 | 'refno' => '16001', |
||
188 | 'errorMessage' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
189 | 'sign' => '8015e6fef2caf41bb11cd2f54077bedb6339bd1aecf418091f77662ee13f81eb', |
||
190 | ], |
||
191 | [ |
||
192 | 'message' => [ |
||
193 | 'status' => 'error', |
||
194 | 'message' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
195 | ], |
||
196 | ], |
||
197 | ], |
||
198 | 'cancel' => [ |
||
199 | [ |
||
200 | 'uppTransactionId' => '876543210987654321', |
||
201 | 'status' => 'cancel', |
||
202 | 'refno' => '16001', |
||
203 | 'sign' => '8015e6fef2caf41bb11cd2f54077bedb6339bd1aecf418091f77662ee13f81eb', |
||
204 | ], |
||
205 | [ |
||
206 | 'message' => [ |
||
207 | 'status' => 'cancel', |
||
208 | 'message' => 'Cancelled', |
||
209 | ], |
||
210 | ], |
||
211 | ], |
||
212 | 'invalid body' => [ |
||
213 | null, |
||
214 | [ |
||
215 | 'message' => [ |
||
216 | 'status' => 'error', |
||
217 | 'message' => 'Parsed body is expected to be an array but got: NULL', |
||
218 | ], |
||
219 | ], |
||
220 | ], |
||
221 | 'invalid status' => [ |
||
222 | [ |
||
223 | 'uppTransactionId' => '123456789012345678', |
||
224 | 'status' => 'non-existing-status', |
||
225 | 'refno' => '16001', |
||
226 | 'amount' => '10000', |
||
227 | 'currency' => 'CHF', |
||
228 | 'responseMessage' => 'Payment was successful', |
||
229 | 'sign' => '811cb0cd3333311a242adb9907052b74d1c462fb94b071ef4d8790faa7f7fd72', |
||
230 | ], |
||
231 | [ |
||
232 | 'message' => [ |
||
233 | 'status' => 'error', |
||
234 | 'message' => 'Unsupported status in Datatrans data: non-existing-status', |
||
235 | ], |
||
236 | ], |
||
237 | ], |
||
238 | 'non-existing order' => [ |
||
239 | [ |
||
240 | 'uppTransactionId' => '123456789012345678', |
||
241 | 'status' => 'success', |
||
242 | 'amount' => '10000', |
||
243 | 'currency' => 'CHF', |
||
244 | 'responseMessage' => 'Payment was successful', |
||
245 | 'sign' => 'd7f9a1716b1538e2cd8f239230526435bc0dcf289a1769f7426badcbaa0efbc8', |
||
246 | ], |
||
247 | [ |
||
248 | 'message' => [ |
||
249 | 'status' => 'error', |
||
250 | 'message' => 'Cannot validate an order without a valid order ID', |
||
251 | ], |
||
252 | ], |
||
253 | ], |
||
254 | 'non-existing amount' => [ |
||
255 | [ |
||
256 | 'uppTransactionId' => '123456789012345678', |
||
257 | 'status' => 'success', |
||
258 | 'refno' => '16001', |
||
259 | 'currency' => 'CHF', |
||
260 | 'responseMessage' => 'Payment was successful', |
||
261 | 'sign' => 'd3f6f15797038879787e6d79e8041a7e9a9cb5cd1d7c5dabdd62ac8d3052db34', |
||
262 | ], |
||
263 | [ |
||
264 | 'message' => [ |
||
265 | 'status' => 'error', |
||
266 | 'message' => 'Cannot validate an order without an amount', |
||
267 | ], |
||
268 | ], |
||
269 | ], |
||
270 | 'invalid currency' => [ |
||
271 | [ |
||
272 | 'uppTransactionId' => '123456789012345678', |
||
273 | 'status' => 'success', |
||
274 | 'refno' => '16001', |
||
275 | 'amount' => '10000', |
||
276 | 'currency' => 'USD', |
||
277 | 'responseMessage' => 'Payment was successful', |
||
278 | 'sign' => '8583b8d14fb4efa85d905ad8646074ce3ce1abe16464299e116e4cb68dd44752', |
||
279 | ], |
||
280 | [ |
||
281 | 'message' => [ |
||
282 | 'status' => 'error', |
||
283 | 'message' => 'Can only accept payment in CHF or EUR, but got: USD', |
||
284 | ], |
||
285 | ], |
||
286 | ], |
||
287 | 'incorrect amount' => [ |
||
288 | [ |
||
289 | 'uppTransactionId' => '123456789012345678', |
||
290 | 'status' => 'success', |
||
291 | 'refno' => '16001', |
||
292 | 'amount' => '1111', |
||
293 | 'currency' => 'CHF', |
||
294 | 'responseMessage' => 'Payment was successful', |
||
295 | 'sign' => '2f2bb61733d8b95101c8c938290acf0efb17daf359266262d73b67165c3ce30b', |
||
296 | ], |
||
297 | [ |
||
298 | 'message' => [ |
||
299 | 'status' => 'error', |
||
300 | 'message' => 'Cannot validate an order with incorrect balance. Expected 10.00 CHF, or 0.00 EUR, but got: 11.11 CHF', |
||
301 | ], |
||
302 | ], |
||
303 | ], |
||
304 | 'incorrect payment method' => [ |
||
305 | [ |
||
306 | 'uppTransactionId' => '123456789012345678', |
||
307 | 'status' => 'success', |
||
308 | 'refno' => '16003', |
||
309 | 'amount' => '10000', |
||
310 | 'currency' => 'CHF', |
||
311 | 'responseMessage' => 'Payment was successful', |
||
312 | 'sign' => '3111e1c3e63a77a13d9ae067690d52523c00c992b7aba262ab41de7f6e81bdad', |
||
313 | ], |
||
314 | [ |
||
315 | 'message' => [ |
||
316 | 'status' => 'error', |
||
317 | 'message' => 'Cannot validate an order whose payment method is: ebanking', |
||
318 | ], |
||
319 | ], |
||
320 | ], |
||
321 | 'incorrect status' => [ |
||
322 | [ |
||
323 | 'uppTransactionId' => '123456789012345678', |
||
324 | 'status' => 'success', |
||
325 | 'refno' => '16002', |
||
326 | 'amount' => '10000', |
||
327 | 'currency' => 'CHF', |
||
328 | 'responseMessage' => 'Payment was successful', |
||
329 | 'sign' => 'f19af94a1cafd91e8da390308e2d4a1f8bfc4ac1e2e18cf2963e1de63cec37f8', |
||
330 | ], |
||
331 | [ |
||
332 | 'message' => [ |
||
333 | 'status' => 'error', |
||
334 | 'message' => 'Cannot validate an order which is already validated', |
||
335 | ], |
||
341 |