Passed
Push — master ( 1c18d9...949a29 )
by
unknown
13:44 queued 13s
created

RemoveUnreferencedCSPDocumentsTask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 7 1
A isEnabled() 0 3 2
1
<?php
2
namespace Signify\Tasks;
3
4
use Signify\Jobs\RemoveUnreferencedCSPDocumentJob;
5
use SilverStripe\Dev\BuildTask;
6
use Symbiote\QueuedJobs\Services\QueuedJobService;
7
8
class RemoveUnreferencedCSPDocumentsTask extends BuildTask
9
{
10
    protected $title = 'Remove unreferenced CSP Document URIs';
11
12
    protected $description = 'CSP Document URIs that are not referenced by a CSP violation report can be safely removed.';
13
14
    /**
15
     * {@inheritDoc}
16
     * @see \SilverStripe\Dev\BuildTask::run()
17
     */
18
    public function run($request)
19
    {
20
        $deletionJob = new RemoveUnreferencedCSPDocumentJob();
21
22
        $jobId = singleton(QueuedJobService::class)->queueJob($deletionJob);
23
24
        print "Job queued with ID $jobId\n";
25
    }
26
27
    public function isEnabled()
28
    {
29
        return parent::isEnabled() && class_exists(QueuedJobService::class);
30
    }
31
32
}