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 |
||
| 8 | class Queue implements QueueInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var \AMQPQueue |
||
| 12 | */ |
||
| 13 | protected $delegate; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var ChannelInterface |
||
| 17 | */ |
||
| 18 | protected $channel; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array<integer, integer> |
||
| 22 | */ |
||
| 23 | protected static $flagMap = [ |
||
| 24 | self::NOPARAM => AMQP_NOPARAM, |
||
| 25 | self::DURABLE => AMQP_DURABLE, |
||
| 26 | self::PASSIVE => AMQP_PASSIVE, |
||
| 27 | self::EXCLUSIVE => AMQP_EXCLUSIVE, |
||
| 28 | self::AUTODELETE => AMQP_AUTODELETE, |
||
| 29 | self::MULTIPLE => AMQP_MULTIPLE, |
||
| 30 | self::AUTOACK => AMQP_AUTOACK, |
||
| 31 | self::REQUEUE => AMQP_REQUEUE, |
||
| 32 | self::IFUNUSED => AMQP_IFUNUSED, |
||
| 33 | self::IFEMPTY => AMQP_IFEMPTY, |
||
| 34 | ]; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param \AMQPQueue $delegate |
||
| 38 | * @param ChannelInterface $channel |
||
| 39 | */ |
||
| 40 | 3 | public function __construct(\AMQPQueue $delegate, ChannelInterface $channel) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * @inheritdoc |
||
| 48 | */ |
||
| 49 | 1 | public function getChannel() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * @inheritdoc |
||
| 56 | */ |
||
| 57 | 1 | public function getConnection() |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @inheritdoc |
||
| 64 | */ |
||
| 65 | 1 | public function setName($name) |
|
| 69 | |||
| 70 | /** |
||
| 71 | * @inheritdoc |
||
| 72 | */ |
||
| 73 | 2 | public function getName() |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @inheritdoc |
||
| 80 | */ |
||
| 81 | 1 | public function setArgument($key, $value) |
|
| 85 | |||
| 86 | /** |
||
| 87 | * @inheritdoc |
||
| 88 | */ |
||
| 89 | 1 | public function setArguments(array $arguments) |
|
| 93 | |||
| 94 | /** |
||
| 95 | * @inheritdoc |
||
| 96 | */ |
||
| 97 | 2 | public function getArgument($key) |
|
| 101 | |||
| 102 | /** |
||
| 103 | * @inheritdoc |
||
| 104 | */ |
||
| 105 | 2 | public function getArguments() |
|
| 109 | |||
| 110 | /** |
||
| 111 | * @inheritdoc |
||
| 112 | */ |
||
| 113 | 1 | public function hasArgument($key) |
|
| 117 | |||
| 118 | /** |
||
| 119 | * @inheritDoc |
||
| 120 | */ |
||
| 121 | 1 | public function setFlags($flags) |
|
| 125 | |||
| 126 | /** |
||
| 127 | * @inheritdoc |
||
| 128 | */ |
||
| 129 | 2 | public function getFlags() |
|
| 133 | |||
| 134 | /** |
||
| 135 | * @inheritdoc |
||
| 136 | */ |
||
| 137 | public function getConsumerTag() |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @inheritdoc |
||
| 144 | */ |
||
| 145 | 1 | public function declareQueue() |
|
| 149 | |||
| 150 | /** |
||
| 151 | * @inheritdoc |
||
| 152 | */ |
||
| 153 | 1 | public function bind($exchangeName, $routingKey, array $arguments = []) |
|
| 157 | |||
| 158 | /** |
||
| 159 | * @inheritdoc |
||
| 160 | */ |
||
| 161 | public function unbind($exchangeName, $routingKey = null, array $arguments = []) |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @inheritdoc |
||
| 168 | */ |
||
| 169 | 1 | View Code Duplication | public function get($flags = null) |
| 177 | |||
| 178 | /** |
||
| 179 | * @inheritdoc |
||
| 180 | */ |
||
| 181 | View Code Duplication | public function consume(callable $callback, $flags = null, $consumerTag = null) |
|
| 189 | |||
| 190 | /** |
||
| 191 | * @inheritdoc |
||
| 192 | */ |
||
| 193 | public function ack($deliveryTag, $flags = null) |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @inheritdoc |
||
| 200 | */ |
||
| 201 | public function nack($deliveryTag, $flags = AMQP_NOPARAM) |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @inheritdoc |
||
| 208 | */ |
||
| 209 | public function reject($deliveryTag, $flags = AMQP_NOPARAM) |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @inheritdoc |
||
| 216 | */ |
||
| 217 | public function cancel($consumerTag = '') |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @inheritdoc |
||
| 224 | */ |
||
| 225 | 3 | public function delete($flags = null) |
|
| 229 | |||
| 230 | /** |
||
| 231 | * @inheritdoc |
||
| 232 | */ |
||
| 233 | public function purge() |
||
| 237 | |||
| 238 | /** |
||
| 239 | * @inheritdoc |
||
| 240 | * |
||
| 241 | * @return \AMQPQueue |
||
| 242 | */ |
||
| 243 | public function getDelegate() |
||
| 247 | |||
| 248 | /** |
||
| 249 | * @param int|null $flags |
||
| 250 | * |
||
| 251 | * @return int |
||
| 252 | */ |
||
| 253 | 4 | View Code Duplication | public static function convertToDelegateFlags($flags = null) |
| 269 | |||
| 270 | /** |
||
| 271 | * @param int|null $flags |
||
| 272 | * |
||
| 273 | * @return int |
||
| 274 | */ |
||
| 275 | 3 | View Code Duplication | public static function convertFromDelegateFlags($flags = null) |
| 291 | } |
||
| 292 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.