Conditions | 4 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public static function setUpBeforeClass() |
||
20 | { |
||
21 | $host = getenv('BEANSTALKD_HOST'); |
||
22 | $className = 'Dtc\QueueBundle\Beanstalkd\Job'; |
||
23 | |||
24 | self::$beanstalkd = new Pheanstalk($host); |
||
25 | |||
26 | self::$jobManager = new JobManager(); |
||
27 | self::$jobManager->setBeanstalkd(self::$beanstalkd); |
||
28 | self::$worker = new FibonacciWorker(); |
||
29 | self::$worker->setJobClass($className); |
||
30 | |||
31 | $drained = 0; |
||
32 | do { |
||
33 | $beanJob = self::$beanstalkd->reserve(1); |
||
34 | if ($beanJob) { |
||
35 | self::$beanstalkd->delete($beanJob); |
||
36 | ++$drained; |
||
37 | } |
||
38 | } while ($beanJob); |
||
39 | |||
40 | if ($drained) { |
||
41 | echo "\nbeanstalkd: drained $drained prior to test\n"; |
||
42 | } |
||
43 | parent::setUpBeforeClass(); |
||
44 | } |
||
45 | |||
58 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.