Conditions | 20 |
Paths | 16 |
Total Lines | 45 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
149 | protected function testLevel3():float{ |
||
150 | $penalty = 0; |
||
151 | |||
152 | foreach($this->matrix->matrix() as $y => $row){ |
||
153 | foreach($row as $x => $val){ |
||
154 | |||
155 | if($x > $this->moduleCount - 7){ |
||
156 | break; |
||
157 | } |
||
158 | |||
159 | if( |
||
160 | $val >> 8 > 0 |
||
161 | && !$this->matrix->check($x + 1, $y) |
||
162 | && $this->matrix->check($x + 2, $y) |
||
163 | && $this->matrix->check($x + 3, $y) |
||
164 | && $this->matrix->check($x + 4, $y) |
||
165 | && !$this->matrix->check($x + 5, $y) |
||
166 | && $this->matrix->check($x + 6, $y) |
||
167 | ){ |
||
168 | $penalty += 40; |
||
169 | } |
||
170 | |||
171 | } |
||
172 | } |
||
173 | |||
174 | for ($x = 0; $x < $this->moduleCount; $x++) { |
||
175 | for ($y = 0; $y < $this->moduleCount - 6; $y++) { |
||
176 | |||
177 | if( |
||
178 | $this->matrix->check($x, $y ) |
||
179 | && !$this->matrix->check($x, $y + 1) |
||
180 | && $this->matrix->check($x, $y + 2) |
||
181 | && $this->matrix->check($x, $y + 3) |
||
182 | && $this->matrix->check($x, $y + 4) |
||
183 | && !$this->matrix->check($x, $y + 5) |
||
184 | && $this->matrix->check($x, $y + 6) |
||
185 | ){ |
||
186 | $penalty += 40; |
||
187 | } |
||
188 | |||
189 | } |
||
190 | } |
||
191 | |||
192 | return $penalty; |
||
193 | } |
||
194 | |||
216 |