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.

DeleteAllJobsTask::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Symbiote\QueuedJobs\Tasks;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Dev\BuildTask;
7
use SilverStripe\ORM\DataObject;
8
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
9
10
/**
11
 * An administrative task to delete all queued jobs records from the database.
12
 * Use with caution!
13
 */
14
class DeleteAllJobsTask extends BuildTask
15
{
16
17
    /**
18
     * @inheritdoc
19
     * @return string
20
     */
21
    public function getTitle()
22
    {
23
        return "Delete all queued jobs.";
24
    }
25
26
    /**
27
     * @inheritdoc
28
     * @return string
29
     */
30
    public function getDescription()
31
    {
32
        return "Remove all queued jobs from the database. Use with caution!";
33
    }
34
35
    /**
36
     * Run the task
37
     * @param HTTPRequest $request
38
     */
39
    public function run($request)
40
    {
41
        $confirm = $request->getVar('confirm');
42
43
        $jobs = DataObject::get(QueuedJobDescriptor::class);
44
45
        if (!$confirm) {
46
            echo "Really delete " . $jobs->count() . " jobs? Please add ?confirm=1 to the URL to confirm.";
47
            return;
48
        }
49
50
        echo "Deleting " . $jobs->count() . " jobs...<br>\n";
51
        $jobs->removeAll();
52
        echo "Done.";
53
    }
54
}
55