Completed
Pull Request — master (#70)
by Daniel
04:46
created

StaticPublishingTriggerPage::generatePublishable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace SilverStripe\StaticPublishQueue\Test\SiteTreePublishingEngineTest\Model;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\ORM\ArrayList;
8
use SilverStripe\StaticPublishQueue\Contract\StaticPublishingTrigger;
9
10
class StaticPublishingTriggerPage extends SiteTree implements TestOnly, StaticPublishingTrigger
11
{
12
13
    public function generatePublishable($url, $prio)
14
    {
15
        $obj = StaticallyPublishablePage::create();
16
        $obj->url = $url;
17
        $obj->prio = $prio;
18
19
        return $obj;
20
    }
21
22 View Code Duplication
    public function objectsToUpdate($context)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        switch ($context['action']) {
25
            case 'publish':
26
                return new ArrayList(array($this->generatePublishable('/updateOnPublish', 10)));
27
            case 'unpublish':
28
                return new ArrayList(array($this->generatePublishable('/updateOnUnpublish', 10)));
29
        }
30
    }
31
32
    /**
33
     * Remove the object on unpublishing (the parent will get updated via objectsToUpdate).
34
     */
35 View Code Duplication
    public function objectsToDelete($context)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        switch ($context['action']) {
38
            case 'publish':
39
                return new ArrayList(array($this->generatePublishable('/deleteOnPublish', 10)));
40
            case 'unpublish':
41
                return new ArrayList(array($this->generatePublishable('/deleteOnUnpublish', 10)));
42
        }
43
    }
44
}
45