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 |
||
| 10 | class Channel implements ChannelInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var AMQPChannel |
||
| 14 | */ |
||
| 15 | private $channel; |
||
| 16 | |||
| 17 | 14 | public function __construct(AMQPChannel $channel) |
|
| 21 | |||
| 22 | 2 | public function wait() |
|
| 26 | |||
| 27 | 1 | public function acknowledge(string $deliveryTag, bool $multiple = false) |
|
| 31 | |||
| 32 | 3 | public function nack(string $deliveryTag, bool $multiple = false, bool $requeue = false) |
|
| 36 | |||
| 37 | 2 | public function consume(Consumable $consumable) : ChannelInterface |
|
| 53 | |||
| 54 | 2 | public function publish(Publishable $message) : ChannelInterface |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param $prefetchSize |
||
| 76 | * @param int $prefetchCount |
||
| 77 | * @param $aGlobal |
||
| 78 | * |
||
| 79 | * @return mixed |
||
| 80 | */ |
||
| 81 | 1 | public function basicQos($prefetchSize = null, int $prefetchCount = 1, $aGlobal = null) |
|
| 87 | |||
| 88 | /** |
||
| 89 | * @param Queue $queue |
||
| 90 | * |
||
| 91 | * @return ChannelInterface |
||
| 92 | */ |
||
| 93 | 2 | View Code Duplication | public function declareQueue(Queue $queue) : ChannelInterface |
| 108 | |||
| 109 | 2 | public function bindQueue(Queue $queue) : ChannelInterface |
|
| 122 | |||
| 123 | 2 | View Code Duplication | public function declareExchange(Exchange $exchange) : ChannelInterface |
| 139 | |||
| 140 | /** |
||
| 141 | * @return array |
||
| 142 | */ |
||
| 143 | 2 | public function getCallbacks() : array |
|
| 147 | |||
| 148 | public function setCallbacks(array $callbacks = []) |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @param Consumable $consumable |
||
| 155 | * |
||
| 156 | * @return AMQPMessage|null |
||
| 157 | */ |
||
| 158 | public function getMessage(Consumable $consumable) |
||
| 162 | } |
||
| 163 |
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.