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 |
||
| 17 | class VoteService implements ListenerInterfaceMpLegacyVote, ListenerInterfaceExpTimer, ListenerInterfaceMpScriptMap |
||
| 18 | { |
||
| 19 | /** @var Console */ |
||
| 20 | protected $console; |
||
| 21 | |||
| 22 | /** @var Connection */ |
||
| 23 | protected $connection; |
||
| 24 | |||
| 25 | /** @var ChatNotification */ |
||
| 26 | protected $chatNotification; |
||
| 27 | |||
| 28 | /** @var Dispatcher */ |
||
| 29 | protected $dispatcher; |
||
| 30 | |||
| 31 | /** @var AbstractFactory[] */ |
||
| 32 | protected $voteFactories = []; |
||
| 33 | |||
| 34 | /** @var array mapping between native MP votes and equivalent expansion votes. */ |
||
| 35 | protected $voteMapping = []; |
||
| 36 | |||
| 37 | /** @var null|AbstractVote */ |
||
| 38 | protected $currentVote = null; |
||
| 39 | |||
| 40 | /** @var array */ |
||
| 41 | protected $votesStarted = []; |
||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | /** |
||
| 46 | * VoteManager constructor. |
||
| 47 | * @param Console $console |
||
| 48 | * @param Connection $connection |
||
| 49 | * @param ChatNotification $chatNotification |
||
| 50 | * @param Dispatcher $dispatcher |
||
| 51 | * @param AbstractFactory[] $voteFactories |
||
| 52 | */ |
||
| 53 | public function __construct( |
||
| 74 | |||
| 75 | /** |
||
| 76 | * When a new vote is addressed |
||
| 77 | * |
||
| 78 | * @param Player $player |
||
| 79 | * @param string $cmdName |
||
| 80 | * @param string $cmdValue |
||
| 81 | * |
||
| 82 | * @return void |
||
| 83 | */ |
||
| 84 | public function onVoteNew(Player $player, $cmdName, $cmdValue) |
||
| 94 | |||
| 95 | /** |
||
| 96 | * When vote gets cancelled |
||
| 97 | * |
||
| 98 | * @param Player $player |
||
| 99 | * @param string $cmdName |
||
| 100 | * @param string $cmdValue |
||
| 101 | * |
||
| 102 | * @return void |
||
| 103 | */ |
||
| 104 | public function onVoteCancelled(Player $player, $cmdName, $cmdValue) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * When vote Passes |
||
| 117 | * @param Player $player |
||
| 118 | * @param string $cmdName |
||
| 119 | * @param string $cmdValue |
||
| 120 | * |
||
| 121 | * @return void |
||
| 122 | */ |
||
| 123 | public function onVotePassed(Player $player, $cmdName, $cmdValue) |
||
| 129 | |||
| 130 | /** |
||
| 131 | * When vote Fails |
||
| 132 | * @param Player $player |
||
| 133 | * @param string $cmdName |
||
| 134 | * @param string $cmdValue |
||
| 135 | * |
||
| 136 | * @return void |
||
| 137 | */ |
||
| 138 | public function onVoteFailed(Player $player, $cmdName, $cmdValue) |
||
| 144 | |||
| 145 | public function onPreLoop() |
||
| 149 | |||
| 150 | public function onPostLoop() |
||
| 154 | |||
| 155 | public function updateVote($login, $type) |
||
| 168 | |||
| 169 | public function onEverySecond() |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @return AbstractVote |
||
| 195 | */ |
||
| 196 | public function getCurrentVote() |
||
| 200 | |||
| 201 | |||
| 202 | public function startVote(Player $player, $type) |
||
| 221 | |||
| 222 | |||
| 223 | /** |
||
| 224 | * Callback sent when the "StartMap" section start. |
||
| 225 | * |
||
| 226 | * @param int $count Each time this section is played, this number is incremented by one |
||
| 227 | * @param int $time Server time when the callback was sent |
||
| 228 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
| 229 | * @param Map $map Map started with. |
||
| 230 | * |
||
| 231 | * @return void |
||
| 232 | */ |
||
| 233 | public function onStartMapStart($count, $time, $restarted, Map $map) |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Callback sent when the "StartMap" section end. |
||
| 240 | * |
||
| 241 | * @param int $count Each time this section is played, this number is incremented by one |
||
| 242 | * @param int $time Server time when the callback was sent |
||
| 243 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
| 244 | * @param Map $map Map started with. |
||
| 245 | * |
||
| 246 | * @return void |
||
| 247 | */ |
||
| 248 | public function onStartMapEnd($count, $time, $restarted, Map $map) |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Callback sent when the "EndMap" section start. |
||
| 255 | * |
||
| 256 | * @param int $count Each time this section is played, this number is incremented by one |
||
| 257 | * @param int $time Server time when the callback was sent |
||
| 258 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
| 259 | * @param Map $map Map started with. |
||
| 260 | * |
||
| 261 | * @return void |
||
| 262 | */ |
||
| 263 | public function onEndMapStart($count, $time, $restarted, Map $map) |
||
| 269 | |||
| 270 | /** |
||
| 271 | * Callback sent when the "EndMap" section end. |
||
| 272 | * |
||
| 273 | * @param int $count Each time this section is played, this number is incremented by one |
||
| 274 | * @param int $time Server time when the callback was sent |
||
| 275 | * @param boolean $restarted true if the map was restarted, false otherwise |
||
| 276 | * @param Map $map Map started with. |
||
| 277 | * |
||
| 278 | * @return void |
||
| 279 | */ |
||
| 280 | public function onEndMapEnd($count, $time, $restarted, Map $map) |
||
| 284 | } |
||
| 285 |
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.