Conditions | 6 |
Paths | 10 |
Total Lines | 54 |
Code Lines | 35 |
Lines | 39 |
Ratio | 72.22 % |
Tests | 22 |
CRAP Score | 10.5 |
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 |
||
113 | 2 | private function onEnd($parser, $name) |
|
1 ignored issue
–
show
|
|||
114 | { |
||
115 | 2 | if (!empty($name)) { |
|
116 | |||
117 | 2 | $this->stack->pop(); |
|
118 | |||
119 | 2 | if ($name === 'ITEM') { |
|
120 | |||
121 | 2 | View Code Duplication | if (array_key_exists('buyingRate', $this->currentRate)) { |
122 | |||
123 | $this->rates[] = new Rate( |
||
124 | NationalBankOfSerbiaDomCrawlerSource::NAME, |
||
125 | $this->currentRate['buyingRate'] / $this->currentRate['unit'], |
||
126 | $this->currentRate['currencyCode'], |
||
127 | $this->rateType . '_buying', |
||
128 | $this->date, |
||
129 | 'RSD', |
||
130 | new \DateTime('now'), |
||
131 | new \DateTime('now') |
||
132 | ); |
||
133 | } |
||
134 | |||
135 | 2 | View Code Duplication | if (array_key_exists('sellingRate', $this->currentRate)) { |
136 | |||
137 | $this->rates[] = new Rate( |
||
138 | NationalBankOfSerbiaDomCrawlerSource::NAME, |
||
139 | $this->currentRate['sellingRate'] / $this->currentRate['unit'], |
||
140 | $this->currentRate['currencyCode'], |
||
141 | $this->rateType . '_selling', |
||
142 | $this->date, |
||
143 | 'RSD', |
||
144 | new \DateTime('now'), |
||
145 | new \DateTime('now') |
||
146 | ); |
||
147 | } |
||
148 | |||
149 | 2 | View Code Duplication | if (array_key_exists('middleRate', $this->currentRate)) { |
150 | |||
151 | 2 | $this->rates[] = new Rate( |
|
152 | 2 | NationalBankOfSerbiaDomCrawlerSource::NAME, |
|
153 | 2 | $this->currentRate['middleRate'] / $this->currentRate['unit'], |
|
154 | 2 | $this->currentRate['currencyCode'], |
|
155 | 2 | 'default', |
|
156 | 2 | $this->date, |
|
157 | 2 | 'RSD', |
|
158 | 2 | new \DateTime('now'), |
|
159 | 2 | new \DateTime('now') |
|
160 | 2 | ); |
|
161 | 2 | } |
|
162 | |||
163 | 2 | $this->currentRate = array(); |
|
164 | 2 | } |
|
165 | 2 | } |
|
166 | 2 | } |
|
167 | |||
222 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.