Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php namespace Cornford\Googlmapper; |
||
| 13 | class Mapper extends MapperBase implements MappingInterface { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Renders and returns Google Map code. |
||
| 17 | * |
||
| 18 | * @param integer $item |
||
| 19 | * |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | public function render($item = -1) |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Search for a location against Google Maps Api. |
||
| 46 | * |
||
| 47 | * @param string $location |
||
| 48 | * |
||
| 49 | * @return mixed |
||
| 50 | */ |
||
| 51 | protected function searchLocation($location) |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Locate a location and return a Location instance. |
||
| 61 | * |
||
| 62 | * @param string $location |
||
| 63 | * |
||
| 64 | * @throws MapperArgumentException |
||
| 65 | * @throws MapperSearchException |
||
| 66 | * @throws MapperSearchResultException |
||
| 67 | * @throws MapperException |
||
| 68 | * |
||
| 69 | * @return Location |
||
| 70 | */ |
||
| 71 | public function location($location) |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Add a new map. |
||
| 109 | * |
||
| 110 | * @param float $latitude |
||
| 111 | * @param float $longitude |
||
| 112 | * @param array $options |
||
| 113 | * |
||
| 114 | * @return self |
||
| 115 | */ |
||
| 116 | public function map($latitude, $longitude, array $options = []) |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Add a new street view map. |
||
| 136 | * |
||
| 137 | * @param float $latitude |
||
| 138 | * @param float $longitude |
||
| 139 | * @param integer $heading |
||
| 140 | * @param integer $pitch |
||
| 141 | * @param array $options |
||
| 142 | * |
||
| 143 | * @return self |
||
| 144 | */ |
||
| 145 | public function streetview($latitude, $longitude, $heading, $pitch, array $options = []) |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Add a new map marker. |
||
| 167 | * |
||
| 168 | * @param float $latitude |
||
| 169 | * @param float $longitude |
||
| 170 | * @param array $options |
||
| 171 | * |
||
| 172 | * @throws MapperException |
||
| 173 | * |
||
| 174 | * @return self |
||
| 175 | */ |
||
| 176 | public function marker($latitude, $longitude, array $options = []) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Add a new map information window. |
||
| 194 | * |
||
| 195 | * @param float $latitude |
||
| 196 | * @param float $longitude |
||
| 197 | * @param string $content |
||
| 198 | * @param array $options |
||
| 199 | * |
||
| 200 | * @throws MapperException |
||
| 201 | * |
||
| 202 | * @return self |
||
| 203 | */ |
||
| 204 | public function informationWindow($latitude, $longitude, $content, array $options = []) |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Add a new map polyline. |
||
| 222 | * |
||
| 223 | * @param array $coordinates |
||
| 224 | * @param array $options |
||
| 225 | * |
||
| 226 | * @throws MapperException |
||
| 227 | * |
||
| 228 | * @return self |
||
| 229 | */ |
||
| 230 | public function polyline(array $coordinates = [], array $options = []) |
||
| 254 | |||
| 255 | /** |
||
| 256 | * Add a new map polygon. |
||
| 257 | * |
||
| 258 | * @param array $coordinates |
||
| 259 | * @param array $options |
||
| 260 | * |
||
| 261 | * @throws MapperException |
||
| 262 | * |
||
| 263 | * @return self |
||
| 264 | */ |
||
| 265 | View Code Duplication | public function polygon(array $coordinates = [], array $options = []) |
|
| 290 | |||
| 291 | /** |
||
| 292 | * Add a new map rectangle. |
||
| 293 | * |
||
| 294 | * @param array $coordinates |
||
| 295 | * @param array $options |
||
| 296 | * |
||
| 297 | * @throws MapperException |
||
| 298 | * |
||
| 299 | * @return self |
||
| 300 | */ |
||
| 301 | View Code Duplication | public function rectangle(array $coordinates = [], array $options = []) |
|
| 326 | |||
| 327 | /** |
||
| 328 | * Add a new map circle. |
||
| 329 | * |
||
| 330 | * @param array $coordinates |
||
| 331 | * @param array $options |
||
| 332 | * |
||
| 333 | * @throws MapperException |
||
| 334 | * |
||
| 335 | * @return self |
||
| 336 | */ |
||
| 337 | View Code Duplication | public function circle(array $coordinates = [], array $options = []) |
|
| 363 | |||
| 364 | } |
||
| 365 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.