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  | 
            ||
| 9 | class JobManager implements JobManagerInterface  | 
            ||
| 10 | { | 
            ||
| 11 | const DEFAULT_RESERVE_TIMEOUT = 5; // seconds  | 
            ||
| 12 | |||
| 13 | /** @var Pheanstalk */  | 
            ||
| 14 | protected $beanstalkd;  | 
            ||
| 15 | |||
| 16 | protected $tube;  | 
            ||
| 17 | |||
| 18 | protected $reserveTimeout = self::DEFAULT_RESERVE_TIMEOUT;  | 
            ||
| 19 | |||
| 20 | public function setBeanstalkd(Pheanstalk $beanstalkd)  | 
            ||
| 24 | |||
| 25 | public function setTube($tube)  | 
            ||
| 29 | |||
| 30 | public function setReserveTimeout($timeout)  | 
            ||
| 34 | |||
| 35 | public function save(\Dtc\QueueBundle\Model\Job $job)  | 
            ||
| 51 | |||
| 52 | public function getJob($workerName = null, $methodName = null, $prioritize = true)  | 
            ||
| 72 | |||
| 73 | public function deleteJob(\Dtc\QueueBundle\Model\Job $job)  | 
            ||
| 78 | |||
| 79 | // Save History get called upon completion of the job  | 
            ||
| 80 | public function saveHistory(\Dtc\QueueBundle\Model\Job $job)  | 
            ||
| 93 | |||
| 94 | View Code Duplication | public function getJobCount($workerName = null, $methodName = null)  | 
            |
| 106 | |||
| 107 | public function getStats()  | 
            ||
| 111 | |||
| 112 | public function resetErroneousJobs($workerName = null, $methodName = null)  | 
            ||
| 116 | |||
| 117 | public function pruneErroneousJobs($workerName = null, $methodName = null)  | 
            ||
| 121 | |||
| 122 | public function getStatus()  | 
            ||
| 126 | }  | 
            ||
| 127 |