Conditions | 1 |
Paths | 1 |
Total Lines | 199 |
Code Lines | 127 |
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 |
||
244 | public function providerShouldInvoiceInitial(): array |
||
245 | { |
||
246 | return [ |
||
247 | 'create MANDATORY booking should invoice' => [ |
||
248 | [ |
||
249 | 'id' => null, |
||
250 | 'previousStatus' => null, |
||
251 | 'status' => BookingStatusType::BOOKED, |
||
252 | 'bookable' => [ |
||
253 | 'creditAccount' => true, |
||
254 | 'initialPrice' => Money::CHF(100), |
||
255 | 'periodicPrice' => Money::CHF(100), |
||
256 | 'bookingType' => BookingTypeType::MANDATORY, |
||
257 | ], |
||
258 | ], |
||
259 | 1, |
||
260 | ], |
||
261 | 'update MANDATORY booking should not invoice' => [ |
||
262 | [ |
||
263 | 'id' => 123, |
||
264 | 'previousStatus' => null, |
||
265 | 'status' => BookingStatusType::BOOKED, |
||
266 | 'bookable' => [ |
||
267 | 'creditAccount' => true, |
||
268 | 'initialPrice' => Money::CHF(100), |
||
269 | 'periodicPrice' => Money::CHF(100), |
||
270 | 'bookingType' => BookingTypeType::MANDATORY, |
||
271 | ], |
||
272 | ], |
||
273 | 0, |
||
274 | ], |
||
275 | 'create MANDATORY booking that is processed (not booked) should not invoice' => [ |
||
276 | [ |
||
277 | 'id' => null, |
||
278 | 'previousStatus' => null, |
||
279 | 'status' => BookingStatusType::PROCESSED, |
||
280 | 'bookable' => [ |
||
281 | 'creditAccount' => true, |
||
282 | 'initialPrice' => Money::CHF(100), |
||
283 | 'periodicPrice' => Money::CHF(100), |
||
284 | 'bookingType' => BookingTypeType::MANDATORY, |
||
285 | ], |
||
286 | ], |
||
287 | 0, |
||
288 | ], |
||
289 | 'create MANDATORY booking that is application (not booked) should not invoice' => [ |
||
290 | [ |
||
291 | 'id' => null, |
||
292 | 'previousStatus' => null, |
||
293 | 'status' => BookingStatusType::APPLICATION, |
||
294 | 'bookable' => [ |
||
295 | 'creditAccount' => true, |
||
296 | 'initialPrice' => Money::CHF(100), |
||
297 | 'periodicPrice' => Money::CHF(100), |
||
298 | 'bookingType' => BookingTypeType::MANDATORY, |
||
299 | ], |
||
300 | ], |
||
301 | 0, |
||
302 | ], |
||
303 | 'create MANDATORY booking without creditAccount should not invoice' => [ |
||
304 | [ |
||
305 | 'id' => null, |
||
306 | 'previousStatus' => null, |
||
307 | 'status' => BookingStatusType::BOOKED, |
||
308 | 'bookable' => [ |
||
309 | 'creditAccount' => false, |
||
310 | 'initialPrice' => Money::CHF(100), |
||
311 | 'periodicPrice' => Money::CHF(100), |
||
312 | 'bookingType' => BookingTypeType::MANDATORY, |
||
313 | ], |
||
314 | ], |
||
315 | 0, |
||
316 | ], |
||
317 | 'create MANDATORY free booking should not invoice' => [ |
||
318 | [ |
||
319 | 'id' => null, |
||
320 | 'previousStatus' => null, |
||
321 | 'status' => BookingStatusType::BOOKED, |
||
322 | 'bookable' => [ |
||
323 | 'creditAccount' => true, |
||
324 | 'initialPrice' => Money::CHF(0), |
||
325 | 'periodicPrice' => Money::CHF(0), |
||
326 | 'bookingType' => BookingTypeType::MANDATORY, |
||
327 | ], |
||
328 | ], |
||
329 | 0, |
||
330 | ], |
||
331 | 'create MANDATORY booking with free initialPrice and non-free periodicPrice should still actually invoice, because we also invoice periodicPrice' => [ |
||
332 | [ |
||
333 | 'id' => null, |
||
334 | 'previousStatus' => null, |
||
335 | 'status' => BookingStatusType::BOOKED, |
||
336 | 'bookable' => [ |
||
337 | 'creditAccount' => true, |
||
338 | 'initialPrice' => Money::CHF(0), |
||
339 | 'periodicPrice' => Money::CHF(100), |
||
340 | 'bookingType' => BookingTypeType::MANDATORY, |
||
341 | ], |
||
342 | ], |
||
343 | 1, |
||
344 | ], |
||
345 | 'create APPLICATION booking should not invoice' => [ |
||
346 | [ |
||
347 | 'id' => null, |
||
348 | 'previousStatus' => null, |
||
349 | 'status' => BookingStatusType::BOOKED, |
||
350 | 'bookable' => [ |
||
351 | 'creditAccount' => true, |
||
352 | 'initialPrice' => Money::CHF(100), |
||
353 | 'periodicPrice' => Money::CHF(100), |
||
354 | 'bookingType' => BookingTypeType::APPLICATION, |
||
355 | ], |
||
356 | ], |
||
357 | 0, |
||
358 | ], |
||
359 | 'update MANDATORY booking to change status from APPLICATION to BOOKED should invoice' => [ |
||
360 | [ |
||
361 | 'id' => 123, |
||
362 | 'previousStatus' => BookingStatusType::APPLICATION, |
||
363 | 'status' => BookingStatusType::BOOKED, |
||
364 | 'bookable' => [ |
||
365 | 'creditAccount' => true, |
||
366 | 'initialPrice' => Money::CHF(100), |
||
367 | 'periodicPrice' => Money::CHF(100), |
||
368 | 'bookingType' => BookingTypeType::MANDATORY, |
||
369 | ], |
||
370 | ], |
||
371 | 1, |
||
372 | ], |
||
373 | 'update MANDATORY booking to change status from BOOKED to BOOKED should not invoice' => [ |
||
374 | [ |
||
375 | 'id' => 123, |
||
376 | 'previousStatus' => BookingStatusType::BOOKED, |
||
377 | 'status' => BookingStatusType::BOOKED, |
||
378 | 'bookable' => [ |
||
379 | 'creditAccount' => true, |
||
380 | 'initialPrice' => Money::CHF(100), |
||
381 | 'periodicPrice' => Money::CHF(100), |
||
382 | 'bookingType' => BookingTypeType::MANDATORY, |
||
383 | ], |
||
384 | ], |
||
385 | 0, |
||
386 | ], |
||
387 | 'update MANDATORY booking to change status from PROCESSED to BOOKED should not invoice' => [ |
||
388 | [ |
||
389 | 'id' => 123, |
||
390 | 'previousStatus' => BookingStatusType::PROCESSED, |
||
391 | 'status' => BookingStatusType::BOOKED, |
||
392 | 'bookable' => [ |
||
393 | 'creditAccount' => true, |
||
394 | 'initialPrice' => Money::CHF(100), |
||
395 | 'periodicPrice' => Money::CHF(100), |
||
396 | 'bookingType' => BookingTypeType::MANDATORY, |
||
397 | ], |
||
398 | ], |
||
399 | 0, |
||
400 | ], |
||
401 | |||
402 | 'create ADMIN_APPROVED booking should invoice' => [ |
||
403 | [ |
||
404 | 'id' => null, |
||
405 | 'previousStatus' => null, |
||
406 | 'status' => BookingStatusType::BOOKED, |
||
407 | 'bookable' => [ |
||
408 | 'creditAccount' => true, |
||
409 | 'initialPrice' => Money::CHF(100), |
||
410 | 'periodicPrice' => Money::CHF(100), |
||
411 | 'bookingType' => BookingTypeType::ADMIN_APPROVED, |
||
412 | ], |
||
413 | ], |
||
414 | 1, |
||
415 | ], |
||
416 | 'update ADMIN_APPROVED booking should not invoice' => [ |
||
417 | [ |
||
418 | 'id' => 123, |
||
419 | 'previousStatus' => null, |
||
420 | 'status' => BookingStatusType::BOOKED, |
||
421 | 'bookable' => [ |
||
422 | 'creditAccount' => true, |
||
423 | 'initialPrice' => Money::CHF(100), |
||
424 | 'periodicPrice' => Money::CHF(100), |
||
425 | 'bookingType' => BookingTypeType::ADMIN_APPROVED, |
||
426 | ], |
||
427 | ], |
||
428 | 0, |
||
429 | ], |
||
430 | 'update ADMIN_APPROVED booking to change status from APPLICATION to BOOKED should invoice' => [ |
||
431 | [ |
||
432 | 'id' => 123, |
||
433 | 'previousStatus' => BookingStatusType::APPLICATION, |
||
434 | 'status' => BookingStatusType::BOOKED, |
||
435 | 'bookable' => [ |
||
436 | 'creditAccount' => true, |
||
437 | 'initialPrice' => Money::CHF(100), |
||
438 | 'periodicPrice' => Money::CHF(100), |
||
439 | 'bookingType' => BookingTypeType::ADMIN_APPROVED, |
||
440 | ], |
||
441 | ], |
||
442 | 1, |
||
443 | ], |
||
447 |