Conditions | 1 |
Paths | 1 |
Total Lines | 81 |
Code Lines | 55 |
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 | // exact interest with future value |
||
93 | [ |
||
94 | 6000, |
||
95 | 2000, |
||
96 | 5, |
||
97 | 360, |
||
98 | 'P1M', |
||
99 | $annuityPaymentAmountCalculator, |
||
100 | $exactCalculationMode, |
||
101 | [1 => 2261.58, 2261.58, 2261.58, 2261.58, 2252.13] |
||
102 | ], |
||
103 | /* Equal principal payments */ |
||
104 | // average interest |
||
105 | [ |
||
106 | 6000, |
||
107 | 0, |
||
108 | 5, |
||
109 | 360, |
||
110 | 'P1M', |
||
111 | $equalPaymentAmountCalculator, |
||
112 | $averageCalculationMode, |
||
113 | [1 => 3000, 2640, 2280, 1920, 1560] |
||
114 | ], |
||
115 | // average interest with future value |
||
116 | [ |
||
117 | 6000, |
||
118 | 2000, |
||
119 | 5, |
||
120 | 360, |
||
121 | 'P1M', |
||
122 | $equalPaymentAmountCalculator, |
||
123 | $averageCalculationMode, |
||
124 | [1 => 2600, 2360, 2120, 1880, 1640] |
||
125 | ], |
||
126 | // exact payment |
||
127 | [ |
||
128 | 6000, |
||
129 | 0, |
||
130 | 5, |
||
131 | 360, |
||
132 | 'P1M', |
||
133 | $equalPaymentAmountCalculator, |
||
134 | $exactCalculationMode, |
||
135 | [1 => 3060, 2592, 2316, 1920, 1572] |
||
136 | ] |
||
137 | ]; |
||
138 | } |
||
139 | } |
||
140 |