@@ -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 | } |
@@ -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 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | public function hasListeners($eventName) |
17 | 17 | { |
18 | - if ( ! isset($this->listeners[$eventName])) { |
|
18 | + if (!isset($this->listeners[$eventName])) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function dispatch($eventName, Event $event) |
26 | 26 | { |
27 | - if ( ! isset($this->listeners[$eventName])) { |
|
27 | + if (!isset($this->listeners[$eventName])) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 |
@@ -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 | } |
@@ -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 |
@@ -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 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->logger->debug("No job to run"); |
52 | 52 | } |
53 | 53 | |
54 | - return; // no job to run |
|
54 | + return; // no job to run |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $this->runJob($job); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | $job->setStatus(Job::STATUS_ERROR); |
83 | - $job->setMessage($e->getMessage() . "\n" .$e->getTraceAsString()); |
|
83 | + $job->setMessage($e->getMessage()."\n".$e->getTraceAsString()); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // save Job history |
@@ -15,12 +15,12 @@ |
||
15 | 15 | |
16 | 16 | public function __construct(AMQPConnection $connection) { |
17 | 17 | $this->connection = $connection; |
18 | - $this->channel = $connection->channel();; |
|
18 | + $this->channel = $connection->channel(); ; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function save($job) { |
22 | 22 | $queue = $job->getWorkerName(); |
23 | - $exchange = null; // User default exchange |
|
23 | + $exchange = null; // User default exchange |
|
24 | 24 | |
25 | 25 | $this->channel->queue_declare($queue, false, true, false, false); |
26 | 26 | $this->channel->exchange_declare($exchange, 'direct', false, true, false); |
@@ -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 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | public function fibonacci($n) |
22 | 22 | { |
23 | - if($n == 0) |
|
23 | + if ($n == 0) |
|
24 | 24 | return 0; //F0 |
25 | 25 | elseif ($n == 1) |
26 | 26 | return 1; //F1 |
@@ -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() { |
@@ -83,7 +83,7 @@ |
||
83 | 83 | public function testPerformance() { |
84 | 84 | $start = microtime(true); |
85 | 85 | $jobsTotal = 1000; |
86 | - self::$jobManager->enableSorting = false; // Ignore priority |
|
86 | + self::$jobManager->enableSorting = false; // Ignore priority |
|
87 | 87 | |
88 | 88 | for ($i = 0; $i < $jobsTotal; $i++) { |
89 | 89 | self::$worker->later()->fibonacci(1); |