Conditions | 1 |
Paths | 1 |
Total Lines | 223 |
Code Lines | 154 |
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 |
||
54 | public function providerProcess(): array |
||
55 | { |
||
56 | return [ |
||
57 | 'normal' => [ |
||
58 | [ |
||
59 | 'uppTransactionId' => '123456789012345678', |
||
60 | 'status' => 'success', |
||
61 | 'refno' => '1007', |
||
62 | 'merchantId' => '123456789', |
||
63 | 'amount' => '10000', |
||
64 | 'currency' => 'CHF', |
||
65 | 'responseMessage' => 'Payment was successful', |
||
66 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
67 | ], |
||
68 | 10096, |
||
69 | Money::CHF(15000), |
||
70 | [ |
||
71 | 'message' => [ |
||
72 | 'status' => 'success', |
||
73 | 'message' => 'Payment was successful', |
||
74 | ], |
||
75 | ], |
||
76 | ], |
||
77 | 'duplicate' => [ |
||
78 | [ |
||
79 | 'uppTransactionId' => '123456789012345678', |
||
80 | 'status' => 'success', |
||
81 | 'refno' => '1007', |
||
82 | 'merchantId' => '123456789', |
||
83 | 'amount' => '10000', |
||
84 | 'currency' => 'CHF', |
||
85 | 'responseMessage' => 'Payment was successful', |
||
86 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
87 | ], |
||
88 | 10096, |
||
89 | Money::CHF(15000), |
||
90 | [ |
||
91 | 'message' => [ |
||
92 | 'status' => 'success', |
||
93 | 'message' => 'Payment was successful', |
||
94 | ], |
||
95 | ], |
||
96 | ], |
||
97 | 'invalid HMAC signature' => [ |
||
98 | [ |
||
99 | 'uppTransactionId' => '123456789012345678', |
||
100 | 'status' => 'success', |
||
101 | 'refno' => '1007', |
||
102 | 'merchantId' => '123456789', |
||
103 | 'amount' => '10000', |
||
104 | 'currency' => 'CHF', |
||
105 | 'responseMessage' => 'Payment was successful', |
||
106 | 'sign' => 'a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0', |
||
107 | ], |
||
108 | 10096, |
||
109 | Money::CHF(5000), |
||
110 | [ |
||
111 | 'message' => [ |
||
112 | 'status' => 'error', |
||
113 | 'message' => 'Invalid HMAC signature', |
||
114 | ], |
||
115 | ], |
||
116 | ], |
||
117 | 'missing HMAC signature' => [ |
||
118 | [ |
||
119 | 'uppTransactionId' => '123456789012345678', |
||
120 | 'status' => 'success', |
||
121 | 'refno' => '1007', |
||
122 | 'merchantId' => '123456789', |
||
123 | 'amount' => '10000', |
||
124 | 'currency' => 'CHF', |
||
125 | 'responseMessage' => 'Payment was successful', |
||
126 | ], |
||
127 | 10096, |
||
128 | Money::CHF(5000), |
||
129 | [ |
||
130 | 'message' => [ |
||
131 | 'status' => 'error', |
||
132 | 'message' => 'Missing HMAC signature', |
||
133 | ], |
||
134 | ], |
||
135 | ], |
||
136 | 'user without account yet (child can credit householder)' => [ |
||
137 | [ |
||
138 | 'uppTransactionId' => '123456789012345678', |
||
139 | 'status' => 'success', |
||
140 | 'refno' => '1008', |
||
141 | 'merchantId' => '123456789', |
||
142 | 'amount' => '10000', |
||
143 | 'currency' => 'CHF', |
||
144 | 'responseMessage' => 'Payment was successful', |
||
145 | 'sign' => '3005b015945fb625ee25d7d804a65cc17f9dacd4fcba72329d34c8081230c146', |
||
146 | ], |
||
147 | 10096, |
||
148 | Money::CHF(15000), |
||
149 | [ |
||
150 | 'message' => [ |
||
151 | 'status' => 'success', |
||
152 | 'message' => 'Payment was successful', |
||
153 | ], |
||
154 | ], |
||
155 | ], |
||
156 | 'error' => [ |
||
157 | [ |
||
158 | 'uppTransactionId' => '876543210987654321', |
||
159 | 'status' => 'error', |
||
160 | 'refno' => '1007', |
||
161 | 'merchantId' => '123456789', |
||
162 | 'errorMessage' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
163 | 'sign' => '38151b15a4c680cccafe9dfff6edb236fa9bf1eeec65799b2720312ae9c4b233', |
||
164 | ], |
||
165 | 10096, |
||
166 | Money::CHF(5000), |
||
167 | [ |
||
168 | 'message' => [ |
||
169 | 'status' => 'error', |
||
170 | 'message' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
171 | ], |
||
172 | ], |
||
173 | ], |
||
174 | 'cancel' => [ |
||
175 | [ |
||
176 | 'uppTransactionId' => '876543210987654321', |
||
177 | 'status' => 'cancel', |
||
178 | 'refno' => '1007', |
||
179 | 'merchantId' => '123456789', |
||
180 | 'sign' => '38151b15a4c680cccafe9dfff6edb236fa9bf1eeec65799b2720312ae9c4b233', |
||
181 | ], |
||
182 | 10096, |
||
183 | Money::CHF(5000), |
||
184 | [ |
||
185 | 'message' => [ |
||
186 | 'status' => 'cancel', |
||
187 | 'message' => 'Cancelled', |
||
188 | ], |
||
189 | ], |
||
190 | ], |
||
191 | 'invalid body' => [ |
||
192 | null, |
||
193 | null, |
||
194 | Money::CHF(0), |
||
195 | [ |
||
196 | 'message' => [ |
||
197 | 'status' => 'error', |
||
198 | 'message' => 'Parsed body is expected to be an array but got: NULL', |
||
199 | ], |
||
200 | ], |
||
201 | ], |
||
202 | 'invalid status' => [ |
||
203 | [ |
||
204 | 'uppTransactionId' => '123456789012345678', |
||
205 | 'status' => 'non-existing-status', |
||
206 | 'refno' => '1007', |
||
207 | 'merchantId' => '123456789', |
||
208 | 'amount' => '10000', |
||
209 | 'currency' => 'CHF', |
||
210 | 'responseMessage' => 'Payment was successful', |
||
211 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
212 | ], |
||
213 | 10096, |
||
214 | Money::CHF(5000), |
||
215 | [ |
||
216 | 'message' => [ |
||
217 | 'status' => 'error', |
||
218 | 'message' => 'Unsupported status in Datatrans data: non-existing-status', |
||
219 | ], |
||
220 | ], |
||
221 | ], |
||
222 | 'non-existing user' => [ |
||
223 | [ |
||
224 | 'uppTransactionId' => '123456789012345678', |
||
225 | 'status' => 'success', |
||
226 | 'merchantId' => '123456789', |
||
227 | 'amount' => '10000', |
||
228 | 'currency' => 'CHF', |
||
229 | 'responseMessage' => 'Payment was successful', |
||
230 | 'sign' => 'f875347d4c66a4f82717ae88f13812289db79b4c1cab4df4fe1c7fdbaaacff05', |
||
231 | ], |
||
232 | null, |
||
233 | Money::CHF(0), |
||
234 | [ |
||
235 | 'message' => [ |
||
236 | 'status' => 'error', |
||
237 | 'message' => 'Cannot create transactions without a user', |
||
238 | ], |
||
239 | ], |
||
240 | ], |
||
241 | 'non-existing amount' => [ |
||
242 | [ |
||
243 | 'uppTransactionId' => '123456789012345678', |
||
244 | 'status' => 'success', |
||
245 | 'merchantId' => '123456789', |
||
246 | 'refno' => '1007', |
||
247 | 'currency' => 'CHF', |
||
248 | 'responseMessage' => 'Payment was successful', |
||
249 | 'sign' => 'e2ca709347d5bec5fd169cd3e1243a95d2eae0abf23a34e26e57698d30b3645d', |
||
250 | ], |
||
251 | 10096, |
||
252 | Money::CHF(5000), |
||
253 | [ |
||
254 | 'message' => [ |
||
255 | 'status' => 'error', |
||
256 | 'message' => 'Cannot create transactions without an amount', |
||
257 | ], |
||
258 | ], |
||
259 | ], |
||
260 | 'invalid currency' => [ |
||
261 | [ |
||
262 | 'uppTransactionId' => '123456789012345678', |
||
263 | 'status' => 'success', |
||
264 | 'refno' => '1007', |
||
265 | 'merchantId' => '123456789', |
||
266 | 'amount' => '10000', |
||
267 | 'currency' => 'USD', |
||
268 | 'responseMessage' => 'Payment was successful', |
||
269 | 'sign' => 'a591b4bb76872f8fcb01f841e4b0cf092ae7c26561e93326243d7f48a9181849', |
||
270 | ], |
||
271 | 10096, |
||
272 | Money::CHF(5000), |
||
273 | [ |
||
274 | 'message' => [ |
||
275 | 'status' => 'error', |
||
276 | 'message' => 'Can only create transactions for CHF, but got: USD', |
||
277 | ], |
||
283 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.