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 |
||
| 11 | class Publisher implements QueueProducerInterface |
||
| 12 | { |
||
| 13 | private $connectionManager; |
||
| 14 | private $channel; |
||
| 15 | private $fromName; |
||
| 16 | private $queueName; |
||
| 17 | private $exchange; |
||
| 18 | private $exchangeType; |
||
| 19 | |||
| 20 | public function __construct( |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param $data |
||
| 36 | * @param $expire |
||
| 37 | * @param $priority |
||
| 38 | */ |
||
| 39 | public function publish($data, $expire = self::DEFAULT_TTL, $priority = self::PRIORITY_LOW) |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return CmobiAMQPChannel |
||
| 53 | */ |
||
| 54 | View Code Duplication | public function refreshChannel() |
|
| 66 | |||
| 67 | /** |
||
| 68 | * @return CmobiAMQPChannel |
||
| 69 | */ |
||
| 70 | public function getChannel() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return string |
||
| 77 | */ |
||
| 78 | public function getQueueName() |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Return caller name. |
||
| 85 | * |
||
| 86 | * @return string |
||
| 87 | */ |
||
| 88 | public function getFromName() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return string |
||
| 95 | */ |
||
| 96 | public function getExchange() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | public function getExchangeType() |
||
| 108 | } |
||
| 109 |