| Conditions | 10 |
| Paths | 130 |
| Total Lines | 31 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 26 | public function createGraph($width, $height){ |
||
| 27 | $this->x_w = $width; |
||
| 28 | $this->y_h = $height; |
||
| 29 | |||
| 30 | $modX = ceil($width/2); |
||
| 31 | $modY = ceil($height/2); |
||
| 32 | |||
| 33 | $relations = array(); |
||
| 34 | for($y = 0; $y <= $height; $y++){ |
||
| 35 | for($x = 0; $x <= $width; $x++){ |
||
| 36 | $k = $x; $k2 = $y; |
||
| 37 | if($x<$modX) $k = $width-$x; |
||
| 38 | if($y<$modY) $k2 = $height-$y; |
||
| 39 | $k3 = $k; |
||
| 40 | if($k2>$k) $k3 = $k2; |
||
| 41 | |||
| 42 | $tmpX = $x-1; $tmpY = $y; |
||
| 43 | if($this->checkParams($tmpX, $tmpY)) $relations["($tmpX,$tmpY)"]["($x,$y)"] = $k3; |
||
| 44 | |||
| 45 | $tmpX2 = $x+1; $tmpY2 = $y; |
||
| 46 | if($this->checkParams($tmpX2, $tmpY2)) $relations["($tmpX2,$tmpY2)"]["($x,$y)"] = $k3; |
||
| 47 | |||
| 48 | $tmpX3 = $x; $tmpY3 = $y-1; |
||
| 49 | if($this->checkParams($tmpX3, $tmpY3)) $relations["($tmpX3,$tmpY3)"]["($x,$y)"] = $k3; |
||
| 50 | |||
| 51 | $tmpX4 = $x; $tmpY4 = $y+1; |
||
| 52 | if($this->checkParams($tmpX4, $tmpY4)) $relations["($tmpX4,$tmpY4)"]["($x,$y)"] = $k3; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | return $relations; |
||
| 57 | } |
||
| 143 |