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 |
||
| 12 | class Marker_Model extends Model_Base { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var WPMarker |
||
| 16 | */ |
||
| 17 | protected $_marker; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return bool |
||
| 21 | */ |
||
| 22 | function has_marker() { |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return Location |
||
| 30 | */ |
||
| 31 | function location() { |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return Marker_Label |
||
| 39 | */ |
||
| 40 | function label() { |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return Info_Window |
||
| 48 | */ |
||
| 49 | function info_window() { |
||
| 57 | 1 | ||
| 58 | 1 | /** |
|
| 59 | 1 | * @param string $method_name |
|
| 60 | 1 | * @param array $args |
|
| 61 | 1 | * |
|
| 62 | * @return mixed|null |
||
| 63 | */ |
||
| 64 | View Code Duplication | function __call( $method_name, $args ) { |
|
| 84 | |||
| 85 | } |
||
| 86 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.