Completed
Pull Request — master (#30)
by
unknown
09:23 queued 02:28
created

CheckComposerUpdatesJob::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Jobs;
4
5
use SilverStripe\Dev\BuildTask;
6
use Symbiote\QueuedJobs\Services\QueuedJob;
7
use SilverStripe\Core\Injector\Injector;
8
use BringYourOwnIdeas\UpdateChecker\Tasks\CheckComposerUpdatesTask;
9
use SilverStripe\Control\HTTPRequest;
10
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
11
12
/**
13
 * Composer update checker job. Runs the check as a queuedjob.
14
 *
15
 * @author Peter Thaleikis
16
 * @license MIT
17
 */
18
class CheckComposerUpdatesJob extends AbstractQueuedJob implements QueuedJob
19
{
20
    /**
21
     * The task to run
22
     *
23
     * @var BuildTask
24
     */
25
    protected $task;
26
27
    /**
28
     * define the title
29
     *
30
     * @return string
31
     */
32
    public function getTitle()
33
    {
34
        return _t(
35
            'ComposerUpdateChecker.Title',
36
            'Check if composer updates are available'
37
        );
38
    }
39
40
    /**
41
     * define the type.
42
     */
43
    public function getJobType()
44
    {
45
        $this->totalSteps = 1;
46
47
        return QueuedJob::QUEUED;
48
    }
49
50
    /**
51
     * init
52
     */
53
    public function setup()
54
    {
55
        // create the instance of the task
56
        $this->task = Injector::inst()->create(CheckComposerUpdatesTask::class);
57
    }
58
59
    /**
60
     * processes the task as a job
61
     */
62
    public function process()
63
    {
64
        // run the task
65
        $this->task->run(new HTTPRequest('GET', '/'));
66
67
        // mark job as completed
68
        $this->isComplete = true;
69
    }
70
}
71