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 Channel extends ObjectStorage |
||
| 13 | { |
||
| 14 | use \PHPDaemon\Traits\EventHandlers; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var Connection |
||
| 18 | */ |
||
| 19 | public $irc; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | public $name; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | public $nicknames = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var |
||
| 33 | */ |
||
| 34 | public $self; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | public $type; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | public $topic; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param Connection $irc |
||
| 48 | * @param string $name |
||
| 49 | */ |
||
| 50 | public function __construct($irc, $name) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @TODO DESCR |
||
| 58 | */ |
||
| 59 | public function who() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @TODO DESCR |
||
| 66 | * @param array|string $mask |
||
| 67 | * @param mixed $msg |
||
| 68 | */ |
||
| 69 | public function onPart($mask, $msg = null) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @TODO DESCR |
||
| 83 | */ |
||
| 84 | public function destroy() |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @TODO DESCR |
||
| 91 | * @param string $type |
||
| 92 | */ |
||
| 93 | public function setChanType($type) |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @TODO DESCR |
||
| 100 | * @return array |
||
| 101 | */ |
||
| 102 | public function exportNicksArray() |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @TODO DESCR |
||
| 113 | * @param string $msg |
||
| 114 | */ |
||
| 115 | public function setTopic($msg) |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @TODO DESCR |
||
| 122 | * @param string $nick |
||
| 123 | * @param string $mode |
||
| 124 | */ |
||
| 125 | View Code Duplication | public function addMode($nick, $mode) |
|
| 136 | |||
| 137 | /** |
||
| 138 | * @TODO DESCR |
||
| 139 | * @param string $target |
||
| 140 | * @param string $mode |
||
| 141 | */ |
||
| 142 | View Code Duplication | public function removeMode($target, $mode) |
|
| 151 | |||
| 152 | /** |
||
| 153 | * @TODO DESCR |
||
| 154 | */ |
||
| 155 | public function join() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @TODO DESCR |
||
| 162 | * @param mixed $msg |
||
| 163 | */ |
||
| 164 | public function part($msg = null) |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @TODO DESCR |
||
| 171 | * @param string $type |
||
| 172 | * @return $this |
||
| 173 | */ |
||
| 174 | public function setType($type) |
||
| 179 | |||
| 180 | /** |
||
| 181 | * @TODO DESCR |
||
| 182 | * @param object $obj |
||
| 183 | */ |
||
| 184 | public function detach($obj) |
||
| 189 | } |
||
| 190 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.