Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
168 | public function testRoundUp() |
||
169 | { |
||
170 | $this->assertEquals( |
||
171 | 17, |
||
172 | MathsHelper::round_up($this->calculateTax($this->price_one)) |
||
173 | ); |
||
174 | |||
175 | $this->assertEquals( |
||
176 | 16.6, |
||
177 | MathsHelper::round_up($this->calculateTax($this->price_one), 1) |
||
178 | ); |
||
179 | |||
180 | $this->assertEquals( |
||
181 | 16.57, |
||
182 | MathsHelper::round_up($this->calculateTax($this->price_one), 2) |
||
183 | ); |
||
184 | |||
185 | $this->assertEquals( |
||
186 | 16.566, |
||
187 | MathsHelper::round_up($this->calculateTax($this->price_one), 3) |
||
188 | ); |
||
189 | |||
190 | $this->assertEquals( |
||
191 | 10, |
||
192 | MathsHelper::round_up($this->calculateTax($this->price_two)) |
||
193 | ); |
||
194 | |||
195 | $this->assertEquals( |
||
196 | 10, |
||
197 | MathsHelper::round_up($this->calculateTax($this->price_two), 1) |
||
198 | ); |
||
199 | |||
200 | $this->assertEquals( |
||
201 | 9.93, |
||
202 | MathsHelper::round_up($this->calculateTax($this->price_two), 2) |
||
203 | ); |
||
204 | |||
205 | $this->assertEquals( |
||
206 | 9.924, |
||
207 | MathsHelper::round_up($this->calculateTax($this->price_two), 3) |
||
208 | ); |
||
209 | |||
210 | $this->assertEquals( |
||
211 | 6, |
||
212 | MathsHelper::round_up($this->calculateTax($this->price_three)) |
||
213 | ); |
||
214 | |||
215 | $this->assertEquals( |
||
216 | 5.7, |
||
217 | MathsHelper::round_up($this->calculateTax($this->price_three), 1) |
||
218 | ); |
||
219 | |||
220 | $this->assertEquals( |
||
221 | 5.67, |
||
222 | MathsHelper::round_up($this->calculateTax($this->price_three), 2) |
||
223 | ); |
||
224 | |||
225 | $this->assertEquals( |
||
226 | 5.668, |
||
227 | MathsHelper::round_up($this->calculateTax($this->price_three), 3) |
||
228 | ); |
||
231 |