| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 44 |
| 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 |
||
| 57 | public function dataLoader(): array |
||
| 58 | { |
||
| 59 | $interestAmountCalculator = new InterestAmountCalculator; |
||
| 60 | |||
| 61 | $annuityPaymentAmountCalculator = new AnnuityPaymentAmountCalculator($interestAmountCalculator); |
||
| 62 | $equalPaymentAmountCalculator = new EqualPrincipalPaymentAmountCalculator($interestAmountCalculator); |
||
| 63 | |||
| 64 | $averageCalculationMode = PeriodInterface::LENGTH_MODE_AVG; |
||
| 65 | $exactCalculationMode = PeriodInterface::LENGTH_MODE_EXACT; |
||
| 66 | |||
| 67 | return [ |
||
| 68 | /* Annuity payments */ |
||
| 69 | // average interest |
||
| 70 | [ |
||
| 71 | 6000, |
||
| 72 | 0, |
||
| 73 | 5, |
||
| 74 | 360, |
||
| 75 | 'P1M', |
||
| 76 | $annuityPaymentAmountCalculator, |
||
| 77 | $averageCalculationMode, |
||
| 78 | [1 => 2463.49, 2463.49, 2463.49, 2463.49, 2463.47] |
||
| 79 | ], |
||
| 80 | // exact interest |
||
| 81 | [ |
||
| 82 | 6000, |
||
| 83 | 0, |
||
| 84 | 5, |
||
| 85 | 360, |
||
| 86 | 'P1M', |
||
| 87 | $annuityPaymentAmountCalculator, |
||
| 88 | $exactCalculationMode, |
||
| 89 | [1 => 2480.94, 2480.94, 2480.94, 2480.94, 2470.53] |
||
| 90 | ], |
||
| 91 | // exact interest with future value |
||
| 92 | [ |
||
| 93 | 6000, |
||
| 94 | 2000, |
||
| 95 | 5, |
||
| 96 | 360, |
||
| 97 | 'P1M', |
||
| 98 | $annuityPaymentAmountCalculator, |
||
| 99 | $exactCalculationMode, |
||
| 100 | [1 => 2261.58, 2261.58, 2261.58, 2261.58, 2252.13] |
||
| 101 | ], |
||
| 102 | /* Equal principal payments */ |
||
| 103 | // average interest |
||
| 104 | [ |
||
| 105 | 6000, |
||
| 106 | 0, |
||
| 107 | 5, |
||
| 108 | 360, |
||
| 109 | 'P1M', |
||
| 110 | $equalPaymentAmountCalculator, |
||
| 111 | $averageCalculationMode, |
||
| 112 | [1 => 3000, 2640, 2280, 1920, 1560] |
||
| 113 | ], |
||
| 114 | // average interest with future value |
||
| 115 | [ |
||
| 116 | 6000, |
||
| 117 | 2000, |
||
| 118 | 5, |
||
| 119 | 360, |
||
| 120 | 'P1M', |
||
| 121 | $equalPaymentAmountCalculator, |
||
| 122 | $averageCalculationMode, |
||
| 123 | [1 => 2600, 2360, 2120, 1880, 1640] |
||
| 124 | ], |
||
| 125 | // exact payment |
||
| 126 | [ |
||
| 127 | 6000, |
||
| 128 | 0, |
||
| 129 | 5, |
||
| 130 | 360, |
||
| 131 | 'P1M', |
||
| 132 | $equalPaymentAmountCalculator, |
||
| 133 | $exactCalculationMode, |
||
| 134 | [1 => 3060, 2592, 2316, 1920, 1572] |
||
| 135 | ] |
||
| 139 |