Completed
Branch dev (ed868c)
by Raffael
03:59
created
src/Scheduler.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     /**
172 172
      * Init queue.
173 173
      */
174
-    public function __construct(Database $db, LoggerInterface $logger, array $config = [], ?Emitter $emitter=null)
174
+    public function __construct(Database $db, LoggerInterface $logger, array $config = [], ?Emitter $emitter = null)
175 175
     {
176 176
         $this->db = $db;
177 177
         $this->logger = $logger;
@@ -412,15 +412,15 @@  discard block
 block discarded – undo
412 412
      *
413 413
      * @param Process[] $stack
414 414
      */
415
-    public function waitFor(array $stack, int $options=0): Scheduler
415
+    public function waitFor(array $stack, int $options = 0): Scheduler
416 416
     {
417 417
         $orig = [];
418 418
         $jobs = array_map(function($job) use(&$orig) {
419
-            if(!($job instanceof Process)) {
419
+            if (!($job instanceof Process)) {
420 420
                 throw new InvalidArgumentException('waitFor() requires a stack of Process[]');
421 421
             }
422 422
 
423
-            $orig[(string)$job->getId()] = $job;
423
+            $orig[(string) $job->getId()] = $job;
424 424
             return $job->getId();
425 425
         }, $stack);
426 426
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                     return $this->waitFor($stack, $options);
441 441
                 }
442 442
 
443
-                $this->events->next($cursor, function () use($stack, $options) {
443
+                $this->events->next($cursor, function() use($stack, $options) {
444 444
                     $this->waitFor($stack, $options);
445 445
                 });
446 446
 
@@ -448,17 +448,17 @@  discard block
 block discarded – undo
448 448
             }
449 449
 
450 450
             $event = $cursor->current();
451
-            $this->events->next($cursor, function () use($stack, $options) {
451
+            $this->events->next($cursor, function() use($stack, $options) {
452 452
                 $this->waitFor($stack, $options);
453 453
             });
454 454
 
455
-            $process = $orig[(string)$event['job']];
455
+            $process = $orig[(string) $event['job']];
456 456
             $data = $process->toArray();
457 457
             $data['status'] = $event['status'];
458 458
             $process->replace(new Process($data, $this));
459 459
             $this->emit($process);
460 460
 
461
-            if($event['status'] < JobInterface::STATUS_DONE) {
461
+            if ($event['status'] < JobInterface::STATUS_DONE) {
462 462
                 continue;
463 463
             } elseif (JobInterface::STATUS_FAILED === $event['status'] && isset($event['exception']) && $options & self::OPTION_THROW_EXCEPTION) {
464 464
                 throw new $event['exception']['class'](
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
             $done++;
471 471
 
472
-            if($done >= $expected) {
472
+            if ($done >= $expected) {
473 473
                 return $this;
474 474
             }
475 475
         }
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
                     return $this->listen($callback, $query);
501 501
                 }
502 502
 
503
-                $this->events->next($cursor, function () use ($callback, $query) {
503
+                $this->events->next($cursor, function() use ($callback, $query) {
504 504
                     return $this->listen($callback, $query);
505 505
                 });
506 506
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             }
509 509
 
510 510
             $result = $cursor->current();
511
-            $this->events->next($cursor, function () use ($callback, $query) {
511
+            $this->events->next($cursor, function() use ($callback, $query) {
512 512
                 $this->listen($callback, $query);
513 513
             });
514 514
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
      */
584 584
     public function updateJobProgress(JobInterface $job, float $progress): self
585 585
     {
586
-        if($progress < 0 || $progress > 100) {
586
+        if ($progress < 0 || $progress > 100) {
587 587
             throw new LogicException('progress may only be between 0 to 100');
588 588
         }
589 589
 
Please login to merge, or discard this patch.
src/Queue.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * Init queue.
84 84
      */
85
-    public function __construct(Scheduler $scheduler, Database $db, WorkerFactoryInterface $factory, LoggerInterface $logger, ?Emitter $emitter=null)
85
+    public function __construct(Scheduler $scheduler, Database $db, WorkerFactoryInterface $factory, LoggerInterface $logger, ?Emitter $emitter = null)
86 86
     {
87 87
         $this->scheduler = $scheduler;
88 88
         $this->db = $db;
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
                         break;
200 200
                     }
201 201
 
202
-                    $this->events->next($cursor_events, function () {
202
+                    $this->events->next($cursor_events, function() {
203 203
                         $this->main();
204 204
                     });
205 205
                 }
206 206
 
207 207
                 $event = $cursor_events->current();
208
-                $this->events->next($cursor_events, function () {
208
+                $this->events->next($cursor_events, function() {
209 209
                     $this->main();
210 210
                 });
211 211
 
212
-                if($event === null) {
212
+                if ($event === null) {
213 213
                     break;
214 214
                 }
215 215
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                     break;
229 229
                 }
230 230
 
231
-                $this->jobs->next($cursor_jobs, function () {
231
+                $this->jobs->next($cursor_jobs, function() {
232 232
                     $this->main();
233 233
                 });
234 234
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
             $job = $cursor_jobs->current();
239 239
 
240
-            $this->jobs->next($cursor_jobs, function () {
240
+            $this->jobs->next($cursor_jobs, function() {
241 241
                 $this->main();
242 242
             });
243 243
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $this->emit($this->scheduler->getJob($event['job']));
254 254
 
255
-        if($event['status'] > JobInterface::STATUS_POSTPONED) {
255
+        if ($event['status'] > JobInterface::STATUS_POSTPONED) {
256 256
             $this->logger->debug('received event ['.$event['status'].'] for job ['.$event['job'].'], write into systemv queue', [
257 257
                 'category' => get_class($this),
258 258
             ]);
Please login to merge, or discard this patch.
src/EventsTrait.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,25 +43,25 @@
 block discarded – undo
43 43
     protected function emit(Process $process): bool
44 44
     {
45 45
         switch ($process->getStatus()) {
46
-             case JobInterface::STATUS_WAITING:
46
+                case JobInterface::STATUS_WAITING:
47 47
                 $this->emitter->emit('taskscheduler.onWaiting', $process);
48 48
                 return true;
49
-             case JobInterface::STATUS_PROCESSING:
49
+                case JobInterface::STATUS_PROCESSING:
50 50
                 $this->emitter->emit('taskscheduler.onStart', $process);
51 51
                 return true;
52
-             case JobInterface::STATUS_DONE:
52
+                case JobInterface::STATUS_DONE:
53 53
                 $this->emitter->emit('taskscheduler.onDone', $process);
54 54
                 return true;
55
-             case JobInterface::STATUS_POSTPONED:
55
+                case JobInterface::STATUS_POSTPONED:
56 56
                 $this->emitter->emit('taskscheduler.onPostponed', $process);
57 57
                 return true;
58
-             case JobInterface::STATUS_FAILED:
58
+                case JobInterface::STATUS_FAILED:
59 59
                 $this->emitter->emit('taskscheduler.onFailed', $process);
60 60
                 return true;
61
-             case JobInterface::STATUS_TIMEOUT:
61
+                case JobInterface::STATUS_TIMEOUT:
62 62
                 $this->emitter->emit('taskscheduler.onTimeout', $process);
63 63
                 return true;
64
-             case JobInterface::STATUS_CANCELED:
64
+                case JobInterface::STATUS_CANCELED:
65 65
                 $this->emitter->emit('taskscheduler.onCancel', $process);
66 66
                 return true;
67 67
         }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
      */
30 30
     public function on(string $event, Closure $handler)
31 31
     {
32
-        if(!in_array($event, Scheduler::VALID_EVENTS)) {
32
+        if (!in_array($event, Scheduler::VALID_EVENTS)) {
33 33
             $name = 'taskscheduler.on'.ucfirst($event);
34 34
         }
35 35
 
Please login to merge, or discard this patch.