Conditions | 11 |
Paths | 11 |
Total Lines | 35 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 25 |
CRAP Score | 12.2657 |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
174 | 2 | private function onData($parser, $data) |
|
1 ignored issue
–
show
|
|||
175 | { |
||
176 | 2 | if (!empty($data)) { |
|
177 | |||
178 | 2 | switch ($this->stack->top()) { |
|
179 | 2 | case 'DATE': |
|
180 | 2 | $this->date = \DateTime::createFromFormat('d.m.Y', $data); |
|
1 ignored issue
–
show
|
|||
181 | 2 | break; |
|
182 | 2 | case 'TYPE': |
|
183 | 2 | $data = trim($data); |
|
184 | 2 | if ($data === 'FOREIGN EXCHANGE') { |
|
185 | $this->rateType = 'foreign_exchange'; |
||
186 | 2 | } elseif ($data === 'FOREIGN CASH') { |
|
187 | $this->rateType = 'foreign_cache'; |
||
188 | } |
||
189 | 2 | break; |
|
190 | 2 | case 'CURRENCY': |
|
191 | 2 | $this->currentRate['currencyCode'] = trim($data); |
|
192 | 2 | break; |
|
193 | 2 | case 'UNIT': |
|
194 | 2 | $this->currentRate['unit'] = (int) trim($data); |
|
195 | 2 | break; |
|
196 | 2 | case 'BUYING_RATE': |
|
197 | $this->currentRate['buyingRate'] = (float) trim($data); |
||
198 | break; |
||
199 | 2 | case 'SELLING_RATE': |
|
200 | $this->currentRate['sellingRate'] = (float) trim($data); |
||
201 | break; |
||
202 | 2 | case 'MIDDLE_RATE': |
|
203 | 2 | $this->currentRate['middleRate'] = (float) trim($data); |
|
204 | 2 | break; |
|
205 | 2 | } |
|
206 | |||
207 | 2 | } |
|
208 | 2 | } |
|
209 | |||
222 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.