| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 39 |
| 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 |
||
| 58 | public function dataLoader(): array |
||
| 59 | { |
||
| 60 | $interestAmountCalculator = new InterestAmountCalculator; |
||
| 61 | |||
| 62 | $annuityPaymentAmountCalculator = new AnnuityPaymentAmountCalculator($interestAmountCalculator); |
||
| 63 | $equalPaymentAmountCalculator = new EqualPrincipalPaymentAmountCalculator($interestAmountCalculator); |
||
| 64 | |||
| 65 | $averageCalculationMode = PeriodInterface::LENGTH_MODE_AVG; |
||
| 66 | $exactCalculationMode = PeriodInterface::LENGTH_MODE_EXACT; |
||
| 67 | |||
| 68 | return [ |
||
| 69 | /* Annuity payments */ |
||
| 70 | // average interest |
||
| 71 | [ |
||
| 72 | 6000, |
||
| 73 | 0, |
||
| 74 | 5, |
||
| 75 | 360, |
||
| 76 | 'P1M', |
||
| 77 | $annuityPaymentAmountCalculator, |
||
| 78 | $averageCalculationMode, |
||
| 79 | [1 => 2463.49, 2463.49, 2463.49, 2463.49, 2463.47] |
||
| 80 | ], |
||
| 81 | // exact interest |
||
| 82 | [ |
||
| 83 | 6000, |
||
| 84 | 0, |
||
| 85 | 5, |
||
| 86 | 360, |
||
| 87 | 'P1M', |
||
| 88 | $annuityPaymentAmountCalculator, |
||
| 89 | $exactCalculationMode, |
||
| 90 | [1 => 2480.94, 2480.94, 2480.94, 2480.94, 2470.53] |
||
| 91 | ], |
||
| 92 | /* Equal principal payments */ |
||
| 93 | // average interest |
||
| 94 | [ |
||
| 95 | 6000, |
||
| 96 | 0, |
||
| 97 | 5, |
||
| 98 | 360, |
||
| 99 | 'P1M', |
||
| 100 | $equalPaymentAmountCalculator, |
||
| 101 | $averageCalculationMode, |
||
| 102 | [1 => 3000, 2640, 2280, 1920, 1560] |
||
| 103 | ], |
||
| 104 | // exact payment |
||
| 105 | [ |
||
| 106 | 6000, |
||
| 107 | 0, |
||
| 108 | 5, |
||
| 109 | 360, |
||
| 110 | 'P1M', |
||
| 111 | $equalPaymentAmountCalculator, |
||
| 112 | $exactCalculationMode, |
||
| 113 | [1 => 3060, 2592, 2316, 1920, 1572] |
||
| 114 | ] |
||
| 115 | ]; |
||
| 116 | } |
||
| 117 | } |
||
| 118 |