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

Task   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 5
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 4 1
A run() 0 17 4
1
<?php
2
3
namespace App\Queue\Dev;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Dev\BuildTask;
7
use SilverStripe\ORM\FieldType\DBDatetime;
8
use SilverStripe\ORM\ValidationException;
9
use Symbiote\QueuedJobs\Services\QueuedJob;
10
use Symbiote\QueuedJobs\Services\QueuedJobService;
11
12
/**
13
 * Class Task
14
 *
15
 * This dev task is intended to be used for testing the queue runner
16
 * use it to create test jobs in your queue so you can run them and observe the whole process
17
 *
18
 * @package App\Queue\Dev
19
 */
20
class Task extends BuildTask
21
{
22
23
    /**
24
     * @var string
25
     */
26
    private static $segment = 'generate-test-jobs-task';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
27
28
    /**
29
     * @return string
30
     */
31
    public function getDescription(): string
32
    {
33
        return 'Create test jobs for queue testing purposes.';
34
    }
35
36
    /**
37
     * @param HTTPRequest $request
38
     * @throws ValidationException
39
     */
40
    public function run($request): void // phpcs:ignore SlevomatCodingStandard.TypeHints
41
    {
42
        echo '<p>Pass GET param ?total=x to create x jobs.</p>';
43
        echo '<p>Pass GET param ?type=(2|3) to create jobs in medium|large queues respectively'
44
            . ' (defaults to large).</p>';
45
46
        $total = $request->getVar('total') ?: 0;
47
        $type = $request->getVar('type') ?: QueuedJob::LARGE;
48
        $service = QueuedJobService::singleton();
49
50
        for ($i = 1; $i <= $total; $i += 1) {
51
            $randomId = $i . DBDatetime::now()->getTimestamp();
52
            $job = new Job();
53
            $job->hydrate((int) $type, (int) $randomId);
54
            $service->queueJob($job);
55
        }
56
    }
57
}
58