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 |
||
| 15 | class RpcClient implements QueueProducerInterface |
||
| 16 | { |
||
| 17 | private $connectionName; |
||
| 18 | private $connectionManager; |
||
| 19 | private $fromName; |
||
| 20 | private $queueName; |
||
| 21 | private $response; |
||
| 22 | private $logOutput; |
||
| 23 | private $errOutput; |
||
| 24 | private $correlationId; |
||
| 25 | private $callbackQueue; |
||
| 26 | |||
| 27 | public function __construct($queueName, ConnectionManager $manager, $fromName, $connectionName = 'default') |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param AMQPMessage $rep |
||
| 39 | */ |
||
| 40 | public function onResponse(AMQPMessage $rep) |
||
| 46 | |||
| 47 | public function createCallbackQueue(CmobiAMQPChannel $channel, $expire, $corralationId = null) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param $data |
||
| 78 | * @param int $expire |
||
| 79 | * @param int $priority |
||
| 80 | * @throws QueueNotFoundException |
||
| 81 | * @throws \Cmobi\RabbitmqBundle\Connection\Exception\NotFoundAMQPConnectionFactoryException |
||
| 82 | */ |
||
| 83 | public function publish($data, $expire = self::DEFAULT_TTL, $priority = self::PRIORITY_LOW) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @return bool |
||
| 119 | */ |
||
| 120 | /** |
||
| 121 | * @param CmobiAMQPChannel $channel |
||
| 122 | * @return bool |
||
| 123 | */ |
||
| 124 | View Code Duplication | public function queueHasExists(CmobiAMQPChannel $channel) |
|
| 134 | |||
| 135 | /** |
||
| 136 | * @return string |
||
| 137 | */ |
||
| 138 | public function getQueueName() |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @return string |
||
| 145 | */ |
||
| 146 | public function getFromName() |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @todo unecessary method set, its only exists to run tests whitout stay jailed in infinite while waiting response. |
||
| 153 | * |
||
| 154 | * @param $content |
||
| 155 | */ |
||
| 156 | public function setResponse($content) |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @return string |
||
| 163 | */ |
||
| 164 | public function getResponse() |
||
| 168 | |||
| 169 | /** @return string */ |
||
| 170 | public function generateCorrelationId() |
||
| 174 | |||
| 175 | /** |
||
| 176 | * @return string |
||
| 177 | */ |
||
| 178 | public function getCurrentCorrelationId() |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @return string |
||
| 185 | */ |
||
| 186 | public function getExchange() |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @return string |
||
| 193 | */ |
||
| 194 | public function getExchangeType() |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return ConnectionManager |
||
| 201 | */ |
||
| 202 | public function getConnectionManager() |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @param CmobiAMQPConnectionInterface $connection |
||
| 209 | * @param $expire |
||
| 210 | * @param $corralationId |
||
| 211 | * @return CmobiAMQPConnectionInterface |
||
| 212 | */ |
||
| 213 | public function forceReconnect(CmobiAMQPConnectionInterface $connection, $expire, $corralationId) |
||
| 233 | } |
||
| 234 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: