@@ -11,6 +11,9 @@ |
||
| 11 | 11 | protected $dm; |
| 12 | 12 | protected $documentName; |
| 13 | 13 | |
| 14 | + /** |
|
| 15 | + * @param string $documentName |
|
| 16 | + */ |
|
| 14 | 17 | public function __construct(DocumentManager $dm, $documentName) |
| 15 | 18 | { |
| 16 | 19 | $this->dm = $dm; |
@@ -179,8 +179,7 @@ |
||
| 179 | 179 | |
| 180 | 180 | if ($prioritize) { |
| 181 | 181 | $qb->sort('priority', 'asc'); |
| 182 | - } |
|
| 183 | - else { |
|
| 182 | + } else { |
|
| 184 | 183 | $qb->sort('when', 'asc'); |
| 185 | 184 | } |
| 186 | 185 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @param field_type $jobClass |
|
| 19 | + * @param string $jobClass |
|
| 20 | 20 | */ |
| 21 | 21 | public function setJobClass($jobClass) |
| 22 | 22 | { |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * @return the $jobManager |
|
| 32 | + * @return JobManagerInterface $jobManager |
|
| 33 | 33 | */ |
| 34 | 34 | public function getJobManager() |
| 35 | 35 | { |
@@ -53,6 +53,9 @@ discard block |
||
| 53 | 53 | return new $this->jobClass($this, $batch, $priority, $dateTime); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** |
|
| 57 | + * @param integer $priority |
|
| 58 | + */ |
|
| 56 | 59 | public function later($delay = 0, $priority = null) |
| 57 | 60 | { |
| 58 | 61 | $job = $this->at(time() + $delay, false, $priority); |
@@ -60,6 +63,9 @@ discard block |
||
| 60 | 63 | return $job; |
| 61 | 64 | } |
| 62 | 65 | |
| 66 | + /** |
|
| 67 | + * @param integer $priority |
|
| 68 | + */ |
|
| 63 | 69 | public function batchLater($delay = 0, $priority = null) |
| 64 | 70 | { |
| 65 | 71 | $job = $this->at($delay, true, $priority); |
@@ -67,6 +73,10 @@ discard block |
||
| 67 | 73 | return $job; |
| 68 | 74 | } |
| 69 | 75 | |
| 76 | + /** |
|
| 77 | + * @param integer $time |
|
| 78 | + * @param integer $priority |
|
| 79 | + */ |
|
| 70 | 80 | public function batchAt($time = null, $priority = null) |
| 71 | 81 | { |
| 72 | 82 | return $this->at($time, true, $priority); |
@@ -45,8 +45,7 @@ |
||
| 45 | 45 | if ($time) { |
| 46 | 46 | $dateTime = new \DateTime(); |
| 47 | 47 | $dateTime->setTimestamp($time); |
| 48 | - } |
|
| 49 | - else { |
|
| 48 | + } else { |
|
| 50 | 49 | $dateTime = null; |
| 51 | 50 | } |
| 52 | 51 | |
@@ -33,6 +33,9 @@ |
||
| 33 | 33 | return $job; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param string $workerName |
|
| 38 | + */ |
|
| 36 | 39 | public function getJob($workerName = null, $methodName = null, $prioritize = true) |
| 37 | 40 | { |
| 38 | 41 | if ($methodName) { |
@@ -57,8 +57,7 @@ |
||
| 57 | 57 | if ($job->getStatus() === BaseJob::STATUS_SUCCESS) { |
| 58 | 58 | $this->beanstalkd |
| 59 | 59 | ->delete($job); |
| 60 | - } |
|
| 61 | - else { |
|
| 60 | + } else { |
|
| 62 | 61 | $this->beanstalkd |
| 63 | 62 | ->bury($job); |
| 64 | 63 | } |
@@ -104,6 +104,11 @@ |
||
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | + /** |
|
| 108 | + * @param integer|null $time |
|
| 109 | + * @param string $method |
|
| 110 | + * @param integer $priority |
|
| 111 | + */ |
|
| 107 | 112 | protected function assertJob(Job $job, $time, $method, $priority = null) { |
| 108 | 113 | $this->assertNotEmpty($job->getId(), "Job should have an id"); |
| 109 | 114 | |
@@ -115,8 +115,7 @@ |
||
| 115 | 115 | if ($priority) { |
| 116 | 116 | $this->assertEquals($priority, $job->getPriority(), |
| 117 | 117 | "Priority should be the same."); |
| 118 | - } |
|
| 119 | - else { |
|
| 118 | + } else { |
|
| 120 | 119 | $this->assertNull($job->getPriority(), "Priority should be null"); |
| 121 | 120 | } |
| 122 | 121 | |
@@ -57,8 +57,7 @@ |
||
| 57 | 57 | if ($job->getStatus() === BaseJob::STATUS_SUCCESS) { |
| 58 | 58 | $this->beanstalkd |
| 59 | 59 | ->delete($job); |
| 60 | - } |
|
| 61 | - else { |
|
| 60 | + } else { |
|
| 62 | 61 | $this->beanstalkd |
| 63 | 62 | ->bury($job); |
| 64 | 63 | } |
@@ -259,8 +259,7 @@ |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | return true; |
| 262 | - } |
|
| 263 | - else { |
|
| 262 | + } else { |
|
| 264 | 263 | return !is_object($args); |
| 265 | 264 | } |
| 266 | 265 | } |
@@ -73,8 +73,7 @@ |
||
| 73 | 73 | // Job finshed successfuly... do we remove the job from database? |
| 74 | 74 | $job->setStatus(Job::STATUS_SUCCESS); |
| 75 | 75 | $job->setMessage(null); |
| 76 | - } |
|
| 77 | - catch (\Exception $e) { |
|
| 76 | + } catch (\Exception $e) { |
|
| 78 | 77 | if ($this->logger) { |
| 79 | 78 | $this->logger->debug("Failed: {$job->getClassName()}->{$job->getMethod()}\n{$e->getMessage()}"); |
| 80 | 79 | } |
@@ -20,12 +20,17 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function fibonacci($n) |
| 22 | 22 | { |
| 23 | - if($n == 0) |
|
| 24 | - return 0; //F0 |
|
| 25 | - elseif ($n == 1) |
|
| 26 | - return 1; //F1 |
|
| 27 | - else |
|
| 28 | - return $this->fibonacci($n - 1) + $this->fibonacci($n - 2); |
|
| 23 | + if($n == 0) { |
|
| 24 | + return 0; |
|
| 25 | + } |
|
| 26 | + //F0 |
|
| 27 | + elseif ($n == 1) { |
|
| 28 | + return 1; |
|
| 29 | + } |
|
| 30 | + //F1 |
|
| 31 | + else { |
|
| 32 | + return $this->fibonacci($n - 1) + $this->fibonacci($n - 2); |
|
| 33 | + } |
|
| 29 | 34 | } |
| 30 | 35 | |
| 31 | 36 | public function getName() { |