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 | 1 | function has_marker() { |
|
| 23 | |||
| 24 | 1 | return $this->_has( '_marker' ); |
|
| 25 | |||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return Location |
||
| 30 | */ |
||
| 31 | 2 | function location() { |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @return Marker_Label |
||
| 39 | */ |
||
| 40 | 1 | function label() { |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @return Info_Window |
||
| 48 | */ |
||
| 49 | 1 | function info_window() { |
|
| 50 | |||
| 51 | 1 | $window = new Info_Window( array( 'info_window' => $this->marker()->info_window() ) ); |
|
| 52 | 1 | $window->set_position( array( 'lat' => $this->marker()->latitude(), 'lng' => $this->marker()->longitude())); |
|
|
|
|||
| 53 | |||
| 54 | 1 | return $window; |
|
| 55 | |||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $method_name |
||
| 60 | * @param array $args |
||
| 61 | * |
||
| 62 | * @return mixed|null |
||
| 63 | */ |
||
| 64 | 1 | 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.