Passed
Pull Request — master (#1834)
by
unknown
05:14
created

NiView::display_front_ni()   B

Complexity

Conditions 8
Paths 12

Size

Total Lines 56
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 35
nc 12
nop 0
dl 0
loc 56
rs 8.1155
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace MySociety\TheyWorkForYou\SectionView;
4
5
class NiView extends SectionView {
6
    public $major = 5;
7
    protected $class = 'NILIST';
8
    protected $index_template = 'section/ni_index';
9
10
    protected function display_front() {
11
        if (get_http_var('more')) {
12
            return parent::display_front();
13
        } else {
14
            $homepage = new \MySociety\TheyWorkForYou\Homepage\NI();
15
            return $homepage->display();
16
        }
17
    }
18
19
    protected function front_content() {
20
        return $this->list->display('biggest_debates', ['days' => 30, 'num' => 20], 'none');
21
    }
22
23
    protected function getURLs($data) {
24
        $urls = [];
25
26
        $day = new \MySociety\TheyWorkForYou\Url('nidebates');
27
        $urls['niday'] = $day;
28
29
        $urls['day'] = $day;
30
31
        return $urls;
32
    }
33
34
    protected function getSearchSections() {
35
        return [
36
            [ 'section' => 'ni' ],
37
        ];
38
    }
39
}
40