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

SeneddView::display_front_senedd()   B

Complexity

Conditions 8
Paths 12

Size

Total Lines 58
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 37
c 1
b 0
f 0
nc 12
nop 0
dl 0
loc 58
rs 8.0835

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 SeneddView extends SectionView {
6
    protected $index_template = 'section/senedd_index';
7
8
    public function __construct() {
9
        if (LANGUAGE == 'cy') {
0 ignored issues
show
introduced by
The condition MySociety\TheyWorkForYou...onView\LANGUAGE == 'cy' is always false.
Loading history...
10
            $this->major = 11;
11
            $this->class = 'SENEDDCYLIST';
12
        } else {
13
            $this->major = 10;
14
            $this->class = 'SENEDDENLIST';
15
        }
16
        parent::__construct();
17
    }
18
19
    protected function display_front() {
20
        if (get_http_var('more')) {
21
            return parent::display_front();
22
        } else {
23
            $homepage = new \MySociety\TheyWorkForYou\Homepage\Wales();
24
            return $homepage->display();
25
        }
26
    }
27
28
    protected function front_content() {
29
        return $this->list->display('biggest_debates', ['days' => 30, 'num' => 20], 'none');
30
    }
31
32
    protected function getURLs($data) {
33
        $urls = [];
34
35
        $day = new \MySociety\TheyWorkForYou\Url('senedddebates');
36
        $urls['seneddday'] = $day;
37
        $urls['day'] = $day;
38
39
        return $urls;
40
    }
41
42
    protected function getSearchSections() {
43
        return [
44
            [ 'section' => 'wales' ],
45
        ];
46
    }
47
}
48