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 JobManager implements JobManagerInterface |
||
| 12 | { |
||
| 13 | /** @var AMQPChannel */ |
||
| 14 | protected $channel; |
||
| 15 | |||
| 16 | /** @var AbstractConnection */ |
||
| 17 | protected $connection; |
||
| 18 | protected $queueArgs; |
||
| 19 | protected $exchangeArgs; |
||
| 20 | |||
| 21 | protected $channelSetup = false; |
||
| 22 | |||
| 23 | public function setExchangeArgs($exchange, $type, $passive, $durable, $autoDelete) |
||
| 27 | |||
| 28 | public function setQueueArgs($queue, $passive, $durable, $exclusive, $autoDelete) |
||
| 32 | |||
| 33 | public function setAMQPConnection(AbstractConnection $connection) |
||
| 38 | |||
| 39 | protected function setupChannel() |
||
| 48 | |||
| 49 | public function save(\Dtc\QueueBundle\Model\Job $job) |
||
| 57 | |||
| 58 | public function getJob($workerName = null, $methodName = null, $prioritize = true) |
||
| 76 | |||
| 77 | public function deleteJob(\Dtc\QueueBundle\Model\Job $job) |
||
| 81 | |||
| 82 | // Save History get called upon completion of the job |
||
| 83 | public function saveHistory(\Dtc\QueueBundle\Model\Job $job) |
||
| 90 | |||
| 91 | public function __destruct() |
||
| 95 | |||
| 96 | View Code Duplication | public function getJobCount($workerName = null, $methodName = null) |
|
| 106 | |||
| 107 | public function resetErroneousJobs($workerName = null, $methodName = null) |
||
| 111 | |||
| 112 | public function pruneErroneousJobs($workerName = null, $methodName = null) |
||
| 116 | |||
| 117 | public function getStatus() |
||
| 121 | } |
||
| 122 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.