Completed
Pull Request — master (#13)
by Robbie
02:33
created

NewsHolderController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 70.37 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 19
loc 27
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A atom() 9 9 1
A rss() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace CWP\CWP\PageTypes;
4
5
use CWP\Core\Feed\CwpAtomFeed;
6
use SilverStripe\Control\RSS\RSSFeed;
7
8
class NewsHolderController extends DatedUpdateHolderController
9
{
10
    private static $allowed_actions = [
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
11
        'rss',
12
        'atom',
13
    ];
14
15 View Code Duplication
    public function rss()
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...
16
    {
17
        $rss = RSSFeed::create(
18
            $this->Updates()->sort('Created DESC')->limit(20),
19
            $this->Link('rss'),
20
            $this->getSubscriptionTitle()
21
        );
22
        $rss->setTemplate('NewsHolder_rss');
23
        return $rss->outputToBrowser();
24
    }
25
26 View Code Duplication
    public function atom()
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...
27
    {
28
        $atom = CwpAtomFeed::create(
29
            $this->Updates()->sort('Created DESC')->limit(20),
30
            $this->Link('atom'),
31
            $this->getSubscriptionTitle()
32
        );
33
        $atom->setTemplate('NewsHolder_atom');
34
        return $atom->outputToBrowser();
35
    }
36
}
37