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.

JobWorker   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A jobqueueExecute() 0 13 3
1
<?php
2
3
namespace Symbiote\QueuedJobs\Workers;
4
5
use SilverStripe\ORM\DataList;
6
use SilverStripe\ORM\FieldType\DBDatetime;
7
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
8
use Symbiote\QueuedJobs\Services\QueuedJobService;
9
10
/**
11
 * @author [email protected]
12
 * @license BSD License http://silverstripe.org/bsd-license/
13
 */
14
15
// GearmanHandler is an extension that could be not available.
16
/**
17
 * @todo Test and implement against it for SilverStripe 4.x compatibility
18
 */
19
if (interface_exists('GearmanHandler')) {
20
    class JobWorker implements \GearmanHandler
21
    {
22
        /**
23
         * @var QueuedJobService
24
         */
25
        public $queuedJobService;
26
27
        /**
28
         * @return string
29
         */
30
        public function getName()
31
        {
32
            return 'jobqueueExecute';
33
        }
34
35
        /**
36
         * @param int $jobId
37
         * @return void
38
         */
39
        public function jobqueueExecute($jobId)
40
        {
41
            $this->queuedJobService->checkJobHealth();
42
            $job = QueuedJobDescriptor::get()->byID($jobId);
43
            if ($job) {
44
                // check that we're not trying to execute something tooo soon
45
                if (strtotime($job->StartAfter) > DBDatetime::now()->getTimestamp()) {
46
                    return;
47
                }
48
49
                $this->queuedJobService->runJob($jobId);
50
            }
51
        }
52
    }
53
}
54