RemoveUnreferencedCSPDocumentsTask   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

2 Methods

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