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