| Conditions | 13 |
| Paths | 65 |
| Total Lines | 36 |
| 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 |
||
| 130 | private function decode($hash){ |
||
| 131 | $ll = array(); |
||
| 132 | $minlat = -90; |
||
| 133 | $maxlat = 90; |
||
| 134 | $minlon = -180; |
||
| 135 | $maxlon = 180; |
||
| 136 | $latE = 90; |
||
| 137 | $lonE = 180; |
||
| 138 | for($i=0,$c=strlen($hash);$i<$c;$i++) { |
||
| 139 | $v = strpos($this->table,$hash[$i]); |
||
| 140 | if(1&$i) { |
||
| 141 | if(16&$v)$minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
||
| 142 | if(8&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
||
| 143 | if(4&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
||
| 144 | if(2&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
||
| 145 | if(1&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
||
| 146 | $latE /= 8; |
||
| 147 | $lonE /= 4; |
||
| 148 | } else { |
||
| 149 | if(16&$v)$minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
||
| 150 | if(8&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
||
| 151 | if(4&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
||
| 152 | if(2&$v) $minlat = ($minlat+$maxlat)/2; else $maxlat = ($minlat+$maxlat)/2; |
||
| 153 | if(1&$v) $minlon = ($minlon+$maxlon)/2; else $maxlon = ($minlon+$maxlon)/2; |
||
| 154 | $latE /= 4; |
||
| 155 | $lonE /= 8; |
||
| 156 | } |
||
| 157 | } |
||
| 158 | $ll['minlat'] = $minlat; |
||
| 159 | $ll['minlon'] = $minlon; |
||
| 160 | $ll['maxlat'] = $maxlat; |
||
| 161 | $ll['maxlon'] = $maxlon; |
||
| 162 | $ll['medlat'] = round(($minlat+$maxlat)/2, max(1, -round(log10($latE)))-1); |
||
| 163 | $ll['medlon'] = round(($minlon+$maxlon)/2, max(1, -round(log10($lonE)))-1); |
||
| 164 | return $ll; |
||
| 165 | } |
||
| 166 | } |
||
| 167 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: