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 |
||
| 25 | class Commit |
||
| 26 | { |
||
| 27 | protected $_hash; |
||
| 28 | protected $_label; |
||
| 29 | protected $_comments = []; |
||
| 30 | |||
| 31 | protected $_date; |
||
| 32 | protected $_author; |
||
| 33 | protected $_subject; |
||
| 34 | |||
| 35 | 2 | public function __construct($hash, $label = null, array $comments = []) |
|
| 41 | |||
| 42 | public function set(Commit $commit) |
||
| 48 | |||
| 49 | 2 | public function setHash($hash) |
|
| 53 | |||
| 54 | 1 | public function getHash() |
|
| 58 | |||
| 59 | 2 | public function setLabel($label) |
|
| 70 | |||
| 71 | 1 | public function getLabel() |
|
| 78 | |||
| 79 | 2 | public function addComment($comment) |
|
| 83 | |||
| 84 | 2 | public function addComments(array $comments) |
|
| 90 | |||
| 91 | 2 | public function setComments($comments) |
|
| 96 | |||
| 97 | 1 | public function getComments() |
|
| 101 | |||
| 102 | 2 | View Code Duplication | public function setDate($value) |
| 110 | |||
| 111 | public function getDate() |
||
| 115 | |||
| 116 | public function setSubject($value) |
||
| 121 | 2 | ||
| 122 | public function getSubject() |
||
| 126 | 1 | ||
| 127 | public function setAuthor($value) |
||
| 132 | |||
| 133 | 2 | public function getAuthor() |
|
| 137 | } |
||
| 138 |
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.