GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#290)
by
unknown
01:34
created

Job::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php
2
3
namespace App\Queue;
4
5
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
6
use Symbiote\QueuedJobs\Services\QueuedJob;
7
8
/**
9
 * Class Job
10
 *
11
 * This job represent a generic job which consumes items and each item is processed in one step
12
 * useful as a template for jobs which need to process multiple items
13
 * item can be an arbitrary piece of data for example: ID or array
14
 *
15
 * @property array $items
16
 * @property array $remaining
17
 * @package App\Queue
18
 */
19
abstract class Job extends AbstractQueuedJob
20
{
21
22
    public function getJobType(): int
23
    {
24
        return QueuedJob::QUEUED;
25
    }
26
27
    public function setup(): void
28
    {
29
        $this->remaining = $this->items;
30
        $this->totalSteps = count($this->items);
31
    }
32
33
    public function process(): void
34
    {
35
        $remaining = $this->remaining;
36
37
        // check for trivial case
38
        if (count($remaining) === 0) {
39
            $this->isComplete = true;
40
41
            return;
42
        }
43
44
        $item = array_shift($remaining);
45
46
        $this->processItem($item);
47
48
        // update job progress
49
        $this->remaining = $remaining;
50
        $this->currentStep += 1;
51
52
        // check for job completion
53
        if (count($remaining) > 0) {
54
            return;
55
        }
56
57
        $this->isComplete = true;
58
    }
59
60
    /**
61
     * @param mixed $item
62
     */
63
    abstract protected function processItem($item): void;
64
}
65