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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 5 1
A getTitle() 0 4 1
A processItem() 0 10 3
1
<?php
2
3
namespace App\Queue\Factory;
4
5
use App\Queue;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\ORM\ValidationException;
8
use Symbiote\QueuedJobs\Services\QueuedJobService;
9
10
/**
11
 * Class Job
12
 *
13
 * generate jobs based on specification
14
 *
15
 * @property string $jobClass
16
 * @package App\Queue\Factory
17
 */
18
class Job extends Queue\Job
19
{
20
21
    public function hydrate(string $jobClass, array $items): void
22
    {
23
        $this->jobClass = $jobClass;
24
        $this->items = $items;
25
    }
26
27
    public function getTitle(): string
28
    {
29
        return 'Factory job';
30
    }
31
32
    /**
33
     * @param mixed $item
34
     * @throws ValidationException
35
     */
36
    protected function processItem($item): void
37
    {
38
        if (!is_array($item) || count($item) === 0) {
39
            return;
40
        }
41
42
        $job = Injector::inst()->create($this->jobClass);
43
        $job->hydrate(array_values($item));
44
        QueuedJobService::singleton()->queueJob($job);
45
    }
46
}
47