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 |
||
34 | public function testRound() |
||
35 | { |
||
36 | $this->assertEquals( |
||
37 | 17, |
||
38 | MathsHelper::round($this->calculateTax($this->price_one)) |
||
39 | ); |
||
40 | |||
41 | $this->assertEquals( |
||
42 | 16.6, |
||
43 | MathsHelper::round($this->calculateTax($this->price_one), 1) |
||
44 | ); |
||
45 | |||
46 | $this->assertEquals( |
||
47 | 16.57, |
||
48 | MathsHelper::round($this->calculateTax($this->price_one), 2) |
||
49 | ); |
||
50 | |||
51 | $this->assertEquals( |
||
52 | 16.566, |
||
53 | MathsHelper::round($this->calculateTax($this->price_one), 3) |
||
54 | ); |
||
55 | |||
56 | $this->assertEquals( |
||
57 | 10, |
||
58 | MathsHelper::round($this->calculateTax($this->price_two)) |
||
59 | ); |
||
60 | |||
61 | $this->assertEquals( |
||
62 | 9.9, |
||
63 | MathsHelper::round($this->calculateTax($this->price_two), 1) |
||
64 | ); |
||
65 | |||
66 | $this->assertEquals( |
||
67 | 9.92, |
||
68 | MathsHelper::round($this->calculateTax($this->price_two), 2) |
||
69 | ); |
||
70 | |||
71 | $this->assertEquals( |
||
72 | 9.924, |
||
73 | MathsHelper::round($this->calculateTax($this->price_two), 3) |
||
74 | ); |
||
75 | |||
76 | $this->assertEquals( |
||
77 | 6, |
||
78 | MathsHelper::round($this->calculateTax($this->price_three)) |
||
79 | ); |
||
80 | |||
81 | $this->assertEquals( |
||
82 | 5.7, |
||
83 | MathsHelper::round($this->calculateTax($this->price_three), 1) |
||
84 | ); |
||
85 | |||
86 | $this->assertEquals( |
||
87 | 5.67, |
||
88 | MathsHelper::round($this->calculateTax($this->price_three), 2) |
||
89 | ); |
||
90 | |||
91 | $this->assertEquals( |
||
92 | 5.668, |
||
93 | MathsHelper::round($this->calculateTax($this->price_three), 3) |
||
94 | ); |
||
231 |