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.

PublishItemsTask   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 14 4
1
<?php
2
3
namespace Symbiote\QueuedJobs\Tasks;
4
5
use Exception;
6
use SilverStripe\Dev\BuildTask;
7
use SilverStripe\ORM\DataObject;
8
use Symbiote\QueuedJobs\Jobs\PublishItemsJob;
9
10
/**
11
 * An example build task that publishes a bunch of pages - this demonstrates a realworld example of how the
12
 * queued jobs project can be used
13
 *
14
 * @author Marcus Nyeholt <[email protected]>
15
 * @license BSD http://silverstripe.org/bsd-license/
16
 */
17
class PublishItemsTask extends BuildTask
18
{
19
    /**
20
     * {@inheritDoc}
21
     * @var string
22
     */
23
    private static $segment = 'PublishItemsTask';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
25
    /**
26
     * @throws Exception
27
     * @param HTTPRequest $request
28
     */
29
    public function run($request)
30
    {
31
        $root = $request->getVar('parent');
32
        if (!$root) {
33
            throw new Exception("Sorry, you must provide a parent node to publish from");
34
        }
35
36
        $item = DataObject::get_by_id('Page', $root);
37
38
        if ($item && $item->exists()) {
39
            $job = new PublishItemsJob($root);
40
            singleton('Symbiote\\QueuedJobs\\Services\\QueuedJobService')->queueJob($job);
41
        }
42
    }
43
}
44