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 | /** |
||
| 28 | * @var string 7 characters commit hash |
||
| 29 | */ |
||
| 30 | protected $_hash; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string string representation of commit |
||
| 34 | */ |
||
| 35 | protected $_label; |
||
| 36 | protected $_comments = []; |
||
| 37 | |||
| 38 | protected $_date; |
||
| 39 | protected $_author; |
||
| 40 | protected $_subject; |
||
| 41 | |||
| 42 | 3 | public function __construct($hash, $label = null, array $comments = []) |
|
| 48 | |||
| 49 | public function set(Commit $commit) |
||
| 55 | |||
| 56 | 3 | public function setHash($hash) |
|
| 60 | |||
| 61 | 3 | public function getHash() |
|
| 65 | |||
| 66 | 3 | public function setLabel($label) |
|
| 78 | |||
| 79 | 3 | public function getLabel() |
|
| 85 | |||
| 86 | 2 | public function addComment($comment) |
|
| 90 | |||
| 91 | 3 | public function addComments(array $comments) |
|
| 97 | |||
| 98 | 3 | public function setComments($comments) |
|
| 103 | |||
| 104 | 3 | public function getComments() |
|
| 108 | |||
| 109 | 3 | View Code Duplication | public function setDate($value) |
| 118 | |||
| 119 | 3 | public function getDate() |
|
| 123 | |||
| 124 | 3 | public function setSubject($value) |
|
| 130 | |||
| 131 | 3 | public function getSubject() |
|
| 135 | |||
| 136 | 3 | public function setAuthor($value) |
|
| 142 | |||
| 143 | 3 | public function getAuthor() |
|
| 147 | } |
||
| 148 |
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.