Conditions | 1 |
Paths | 1 |
Total Lines | 209 |
Code Lines | 136 |
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 |
||
134 | protected function requestPostCustomerFailsValidationDataProvider(): array |
||
135 | { |
||
136 | return [ |
||
137 | [ |
||
138 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
139 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
140 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456', |
||
141 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => false, |
||
142 | ]))->build(), |
||
143 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
144 | 'errors' => [ |
||
145 | [ |
||
146 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
147 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
148 | RestErrorMessageTransfer::DETAIL => 'acceptedTerms => This value should be true.', |
||
149 | ], |
||
150 | ], |
||
151 | ], |
||
152 | [ |
||
153 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
154 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
155 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456', |
||
156 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
157 | RestCustomersAttributesTransfer::SALUTATION => 'xyz', |
||
158 | ]))->build(), |
||
159 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
160 | 'errors' => [ |
||
161 | [ |
||
162 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
163 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
164 | RestErrorMessageTransfer::DETAIL => 'salutation => The value you selected is not a valid choice.', |
||
165 | ], |
||
166 | ], |
||
167 | ], |
||
168 | [ |
||
169 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
170 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
171 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456', |
||
172 | ]))->build(), |
||
173 | RestErrorMessageTransfer::STATUS => Response::HTTP_BAD_REQUEST, |
||
174 | 'errors' => [ |
||
175 | [ |
||
176 | RestErrorMessageTransfer::CODE => CustomersRestApiConfig::RESPONSE_CODE_NOT_ACCEPTED_TERMS, |
||
177 | RestErrorMessageTransfer::STATUS => Response::HTTP_BAD_REQUEST, |
||
178 | RestErrorMessageTransfer::DETAIL => CustomersRestApiConfig::RESPONSE_DETAILS_NOT_ACCEPTED_TERMS, |
||
179 | ], |
||
180 | ], |
||
181 | ], |
||
182 | [ |
||
183 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
184 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
185 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!234564', |
||
186 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
187 | ]))->build(), |
||
188 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
189 | 'errors' => [ |
||
190 | [ |
||
191 | RestErrorMessageTransfer::CODE => CustomersRestApiConfig::RESPONSE_CODE_PASSWORDS_DONT_MATCH, |
||
192 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
193 | RestErrorMessageTransfer::DETAIL => sprintf( |
||
194 | CustomersRestApiConfig::RESPONSE_DETAILS_PASSWORDS_DONT_MATCH, |
||
195 | RestCustomersAttributesTransfer::PASSWORD, |
||
196 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD, |
||
197 | ), |
||
198 | ], |
||
199 | ], |
||
200 | ], |
||
201 | [ |
||
202 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
203 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456', |
||
204 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
205 | ]))->build(), |
||
206 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
207 | 'errors' => [ |
||
208 | [ |
||
209 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
210 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
211 | RestErrorMessageTransfer::DETAIL => 'password => This value should not be blank.', |
||
212 | ], |
||
213 | ], |
||
214 | ], |
||
215 | [ |
||
216 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
217 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
218 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
219 | ]))->build(), |
||
220 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
221 | 'errors' => [ |
||
222 | [ |
||
223 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
224 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
225 | RestErrorMessageTransfer::DETAIL => 'confirmPassword => This value should not be blank.', |
||
226 | ], |
||
227 | ], |
||
228 | ], |
||
229 | [ |
||
230 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
231 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456pqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuioppqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwert', |
||
232 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456pqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuioppqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwert', |
||
233 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
234 | ]))->build(), |
||
235 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
236 | 'errors' => [ |
||
237 | [ |
||
238 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
239 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
240 | RestErrorMessageTransfer::DETAIL => 'password => This value is too long. It should have 128 characters or less.', |
||
241 | ], |
||
242 | [ |
||
243 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
244 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
245 | RestErrorMessageTransfer::DETAIL => 'confirmPassword => This value is too long. It should have 128 characters or less.', |
||
246 | ], |
||
247 | ], |
||
248 | ], |
||
249 | [ |
||
250 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
251 | RestCustomersAttributesTransfer::PASSWORD => 'qwe', |
||
252 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'qwe', |
||
253 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
254 | ]))->build(), |
||
255 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
256 | 'errors' => [ |
||
257 | [ |
||
258 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
259 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
260 | RestErrorMessageTransfer::DETAIL => 'password => This value is too short. It should have 12 characters or more.', |
||
261 | ], |
||
262 | [ |
||
263 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
264 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
265 | RestErrorMessageTransfer::DETAIL => 'password => Your password must include at least one uppercase letter, one lowercase letter, one number, and one special character from the following list: !@#$%^&*()_-+=[]{}|;:<>.,/?\~. Non-Latin and other special characters are not allowed.', |
||
266 | ], |
||
267 | [ |
||
268 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
269 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
270 | RestErrorMessageTransfer::DETAIL => 'confirmPassword => This value is too short. It should have 12 characters or more.', |
||
271 | ], |
||
272 | ], |
||
273 | ], |
||
274 | [ |
||
275 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
276 | RestCustomersAttributesTransfer::PASSWORD => 'qwertyuI1!eee', |
||
277 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'qwertyuI1!eee', |
||
278 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
279 | ]))->build(), |
||
280 | RestErrorMessageTransfer::STATUS => Response::HTTP_BAD_REQUEST, |
||
281 | 'errors' => [ |
||
282 | [ |
||
283 | RestErrorMessageTransfer::CODE => CustomersRestApiConfig::RESPONSE_CODE_CUSTOMER_PASSWORD_SEQUENCE_NOT_ALLOWED, |
||
284 | RestErrorMessageTransfer::STATUS => Response::HTTP_BAD_REQUEST, |
||
285 | RestErrorMessageTransfer::DETAIL => CustomersRestApiConfig::RESPONSE_MESSAGE_CUSTOMER_PASSWORD_SEQUENCE_NOT_ALLOWED, |
||
286 | ], |
||
287 | ], |
||
288 | ], |
||
289 | [ |
||
290 | 'attributes' => (new RestCustomersAttributesBuilder([ |
||
291 | RestCustomersAttributesTransfer::PASSWORD => 'Change!23456', |
||
292 | RestCustomersAttributesTransfer::CONFIRM_PASSWORD => 'Change!23456', |
||
293 | RestCustomersAttributesTransfer::ACCEPTED_TERMS => true, |
||
294 | RestCustomersAttributesTransfer::GENDER => 'xyz', |
||
295 | ]))->build(), |
||
296 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
297 | 'errors' => [ |
||
298 | [ |
||
299 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
300 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
301 | RestErrorMessageTransfer::DETAIL => 'gender => The value you selected is not a valid choice.', |
||
302 | ], |
||
303 | ], |
||
304 | ], |
||
305 | [ |
||
306 | 'attributes' => new RestCustomersAttributesTransfer(), |
||
307 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
308 | 'errors' => [ |
||
309 | [ |
||
310 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
311 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
312 | RestErrorMessageTransfer::DETAIL => 'email => This value should not be blank.', |
||
313 | ], |
||
314 | [ |
||
315 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
316 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
317 | RestErrorMessageTransfer::DETAIL => 'gender => This value should not be blank.', |
||
318 | ], |
||
319 | [ |
||
320 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
321 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
322 | RestErrorMessageTransfer::DETAIL => 'salutation => This value should not be blank.', |
||
323 | ], |
||
324 | [ |
||
325 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
326 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
327 | RestErrorMessageTransfer::DETAIL => 'firstName => This value should not be blank.', |
||
328 | ], |
||
329 | [ |
||
330 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
331 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
332 | RestErrorMessageTransfer::DETAIL => 'lastName => This value should not be blank.', |
||
333 | ], |
||
334 | [ |
||
335 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
336 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
337 | RestErrorMessageTransfer::DETAIL => 'password => This value should not be blank.', |
||
338 | ], |
||
339 | [ |
||
340 | RestErrorMessageTransfer::CODE => RestRequestValidatorConfig::RESPONSE_CODE_REQUEST_INVALID, |
||
341 | RestErrorMessageTransfer::STATUS => Response::HTTP_UNPROCESSABLE_ENTITY, |
||
342 | RestErrorMessageTransfer::DETAIL => 'confirmPassword => This value should not be blank.', |
||
343 | ], |
||
349 |