Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 34 |
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 |
||
101 | public function testRoundDown() |
||
102 | { |
||
103 | $this->assertEquals( |
||
104 | 16, |
||
105 | MathsHelper::round_down($this->calculateTax($this->price_one)) |
||
106 | ); |
||
107 | |||
108 | $this->assertEquals( |
||
109 | 16.5, |
||
110 | MathsHelper::round_down($this->calculateTax($this->price_one), 1) |
||
111 | ); |
||
112 | |||
113 | $this->assertEquals( |
||
114 | 16.56, |
||
115 | MathsHelper::round_down($this->calculateTax($this->price_one), 2) |
||
116 | ); |
||
117 | |||
118 | $this->assertEquals( |
||
119 | 16.566, |
||
120 | MathsHelper::round_down($this->calculateTax($this->price_one), 3) |
||
121 | ); |
||
122 | |||
123 | $this->assertEquals( |
||
124 | 9, |
||
125 | MathsHelper::round_down($this->calculateTax($this->price_two)) |
||
126 | ); |
||
127 | |||
128 | $this->assertEquals( |
||
129 | 9.9, |
||
130 | MathsHelper::round_down($this->calculateTax($this->price_two), 1) |
||
131 | ); |
||
132 | |||
133 | $this->assertEquals( |
||
134 | 9.92, |
||
135 | MathsHelper::round_down($this->calculateTax($this->price_two), 2) |
||
136 | ); |
||
137 | |||
138 | $this->assertEquals( |
||
139 | 9.924, |
||
140 | MathsHelper::round_down($this->calculateTax($this->price_two), 3) |
||
141 | ); |
||
142 | |||
143 | $this->assertEquals( |
||
144 | 5, |
||
145 | MathsHelper::round_down($this->calculateTax($this->price_three)) |
||
146 | ); |
||
147 | |||
148 | $this->assertEquals( |
||
149 | 5.6, |
||
150 | MathsHelper::round_down($this->calculateTax($this->price_three), 1) |
||
151 | ); |
||
152 | |||
153 | $this->assertEquals( |
||
154 | 5.66, |
||
155 | MathsHelper::round_down($this->calculateTax($this->price_three), 2) |
||
156 | ); |
||
157 | |||
158 | $this->assertEquals( |
||
159 | 5.668, |
||
160 | MathsHelper::round_down($this->calculateTax($this->price_three), 3) |
||
161 | ); |
||
231 |