SectionView::display_year()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
# For displaying any debate calendar, day, debate, speech page or related.
4
5
namespace MySociety\TheyWorkForYou\SectionView;
6
7
class SectionView {
8
    public $major;
9
    protected $class;
10
    protected $list;
11
    private $major_data;
12
    private $page_base;
13
    protected $index_template = '';
14
    protected $location;
15
    protected $assembly;
16
17
    public function __construct() {
18
        global $hansardmajors;
19
        $this->major_data = $hansardmajors[$this->major];
20
        $this->page_base = str_replace('year', '', $this->major_data['page_year']);
21
        if (!$this->list) {
22
            $this->class = "\\" . $this->class;
23
            $this->list = new $this->class();
24
        }
25
26
        [$country, $location, $assembly] = $this->getCountryDetails();
27
        $this->location = $location;
28
        $this->assembly = $assembly;
29
    }
30
31
    public function display() {
32
        if ($year = get_http_var('y')) {
33
            $data = $this->display_year($year);
34
            $data['year'] = $year;
35
            $data['template'] = 'section/year';
36
            $data = $this->addCommonData($data);
37
        } elseif (($date = get_http_var('d')) && ($column = get_http_var('c'))) {
38
            $data = $this->display_column($date, $column);
39
            $data = $this->addCommonData($data);
40
        } elseif ($date = get_http_var('d')) {
41
            $data = $this->display_day($date);
42
            if (!isset($data['template'])) {
43
                $data['template'] = 'section/day';
44
            }
45
            $data = $this->addCommonData($data);
46
        } elseif (get_http_var('id')) {
47
            $data = $this->display_section_or_speech();
48
        } else {
49
            $data = $this->display_front();
50
            if (!isset($data['template'])) {
51
                $data['template'] = 'section/recent';
52
            }
53
            $data['search_sections'] = $this->getSearchSections();
54
            $data = $this->addCommonData($data);
55
        }
56
57
        $data['location'] = $this->location;
58
        $data['current_assembly'] = $this->assembly;
59
60
        return $data;
61
    }
62
63
    protected function addCommonData($data) {
64
        global $DATA, $this_page;
65
66
        $common = new \MySociety\TheyWorkForYou\Common();
0 ignored issues
show
Unused Code introduced by
The assignment to $common is dead and can be removed.
Loading history...
67
        $data['urls'] = $this->getURLs($data);
68
        $data['popular_searches'] = []; #$common->getPopularSearches();
69
        $data['recess_major'] = $this->getRecessMajor();
70
71
        $nextprev = $DATA->page_metadata($this_page, 'nextprev');
72
        if (isset($nextprev['next']['url'])) {
73
            $data['next'] = $nextprev['next'];
74
        }
75
        if (isset($nextprev['prev']['url'])) {
76
            $data['prev'] = $nextprev['prev'];
77
        }
78
79
        $parent_page = $DATA->page_metadata($this_page, 'parent');
80
        $data['title'] = $DATA->page_metadata($this_page, 'title');
81
        if (!isset($data['title']) && $parent_page != '') {
82
            $data['title'] = $DATA->page_metadata($parent_page, 'title');
83
        }
84
        if ($parent_page) {
85
            $data['parent_title'] = $DATA->page_metadata($parent_page, 'title');
86
        }
87
88
        $data['section'] = $this->pageToSection();
89
90
        return $data;
91
    }
92
93
    protected function getURLs($data) {
94
        global $DATA, $this_page;
95
96
        $urls = [];
97
98
        $urls = array_merge($urls, $this->getViewUrls());
99
100
        if (isset($data['info']['page'])) {
101
            $day = new \MySociety\TheyWorkForYou\Url($data['info']['page']);
102
            $urls['day'] = $day;
103
        }
104
105
        return $urls;
106
    }
107
108
    protected function getViewUrls() {
109
        $urls = [];
110
        $day = new \MySociety\TheyWorkForYou\Url('debates');
111
        $urls['debatesday'] = $day;
112
        $urls['day'] = $day;
113
        $day = new \MySociety\TheyWorkForYou\Url('whall');
114
        $urls['whallday'] = $day;
115
        $day = new \MySociety\TheyWorkForYou\Url('lordsdebates');
116
        $urls['lordsday'] = $day;
117
        return $urls;
118
    }
119
120
    protected function getSearchSections() {
121
        return [];
122
    }
123
124
    protected function getRecessMajor() {
125
        $recess_major = 1; # For all of UK Parliament
126
        if ($this->major_data['location'] == 'NI') {
127
            $recess_major = 5;
128
        } elseif ($this->major_data['location'] == 'Scotland') {
129
            $recess_major = 4; # For all of Scotland
130
        } elseif ($this->major == 101) {
131
            $recess_major = 101; # Lords slightly different
132
        }
133
134
        return $recess_major;
135
    }
136
137
    protected function display_year($year) {
138
        global $this_page, $PAGE, $DATA;
139
        $this_page = $this->page_base . 'year';
140
        if (is_numeric($year)) {
141
            $DATA->set_page_metadata($this_page, 'title', $year);
142
        }
143
144
        $args =  [ 'year' => $year ];
145
        $data = $this->list->display('calendar', $args, 'none');
146
        return $data;
147
    }
148
149
    protected function display_column($date, $column) {
150
        global $this_page;
151
        $this_page = $this->page_base;
152
        $args = [ 'date' => $date, 'column' => $column ];
153
        $content = $this->list->display('column', $args, 'none');
154
155
        $data = [];
156
        $data['column'] = $column;
157
        $URL = new \MySociety\TheyWorkForYou\Url($this->list->listpage);
158
        $URL->insert(['d' => $date]);
159
        $data['debate_day_link'] = $URL->generate();
160
        $data['debate_day_human'] = format_date($date, LONGDATEFORMAT);
161
162
        $data['rows'] = $content;
163
        $data['info'] = ['major' => $this->major, 'date' => $date];
164
165
        $data['template'] = 'section/column';
166
        return $data;
167
    }
168
169
    protected function display_day($date) {
170
        global $this_page;
171
        $this_page = $this->page_base . 'day';
172
        $args =  [ 'date' => get_http_var('d') ];
173
        $data = $this->list->display('date', $args, 'none');
174
        [$year, $month, $day] = explode('-', $date);
175
        $args = [ 'year' => $year, 'month' => $month, 'day' => $day];
176
        $calendar = $this->list->display('calendar', $args, 'none');
177
        if (isset($calendar['years'])) {
178
            $data['calendar'] = $calendar['years'];
179
        }
180
        return $data;
181
    }
182
183
    protected function display_section_or_speech($args = []) {
184
        global $DATA, $this_page, $THEUSER;
185
186
        # += as we *don't* want to override any already supplied argument
187
        $args +=  [
188
            'gid' => get_http_var('id'),
189
            's' => get_http_var('s'), // Search terms to be highlighted.
190
            'member_id' => get_http_var('m'), // Member's speeches to be highlighted.
191
        ];
192
193
        if (preg_match('/speaker:(\d+)/', get_http_var('s'), $mmm)) {
194
            $args['person_id'] = $mmm[1];
195
        }
196
197
        try {
198
            $data = $this->list->display('gid', $args, 'none');
199
        } catch (\RedirectException $e) {
200
            $URL = new \MySociety\TheyWorkForYou\Url($this->major_data['page_all']);
201
            if ($this->major == 6) {
202
                # Magically (as in I can't remember quite why), pbc_clause will
203
                # contain the new URL without any change...
204
                $URL->remove(['id']);
205
            } else {
206
                $URL->insert(['id' => $e->getMessage()]);
207
            }
208
            # put the search term back in so highlighting works.
209
            # NB: as we don't see the # part of the URL we lose this :(
210
            if ($args['s'] !== '') {
211
                $URL->insert(['s' => $args['s']]);
212
            }
213
            redirect($URL->generate('none'), 301);
214
        }
215
216
        $data['individual_item'] = ($this->list->commentspage == $this_page);
217
218
        if ($data['individual_item']) {
219
            $COMMENTLIST = new \COMMENTLIST();
220
            $args['user_id'] = get_http_var('u');
221
            $args['epobject_id'] = $this->list->epobject_id();
222
            $data['comments']['object'] = $COMMENTLIST;
223
            $data['comments']['args'] = $args;
224
            $data['comments']['commentdata'] = [
225
                'epobject_id' => $this->list->epobject_id(),
226
                'gid' => get_http_var('id'), # wrans is LIST->gid?
227
                'return_page' => $this_page,
228
            ];
229
        }
230
231
        if (!isset($data['info'])) {
232
            header("HTTP/1.0 404 Not Found");
233
            $data['template'] = 'error';
234
            return $data;
235
        }
236
237
        # Okay, let's set up highlighting and glossarisation
238
239
        [$bodies, $speeches] = $this->highlightSpeeches($data);
240
241
        [$data, $first_speech, $subsection_title] = $this->annotateSpeeches($data, $bodies, $speeches);
242
243
        $data = $this->setTitleAndAlertText($data, $subsection_title);
244
245
        if ($first_speech) {
246
            $data['debate_time_human'] = format_time($first_speech['htime'], TIMEFORMAT);
247
        }
248
        $data['debate_day_human'] = format_date($data['info']['date'], LONGDATEFORMAT);
249
250
        $URL = new \MySociety\TheyWorkForYou\Url($this->list->listpage);
251
        $URL->insert(['d' => $data['info']['date']]);
252
        $URL->remove(['id']);
253
        $data['debate_day_link'] = $URL->generate();
254
255
        $data['nextprev'] = $DATA->page_metadata($this_page, 'nextprev');
256
257
        if (isset($THEUSER) && $THEUSER->postcode_is_set()) {
258
            $user = new \MySociety\TheyWorkForYou\User();
259
            $house = \MySociety\TheyWorkForYou\Utility\House::majorToHouse($this->major)[0];
260
            $data['mp_data'] = $user->getRep($this->majorToConsType(), $house);
261
        }
262
263
        $DATA->set_page_metadata($this_page, 'meta_description', sprintf(
264
            "%s %s%s %s",
265
            $data['intro'],
266
            $this->location,
267
            isset($data['debate_time_human']) ? " at $data[debate_time_human]" : '',
268
            $data['debate_day_human']
269
        ));
270
271
        return $data;
272
    }
273
274
    private function setTitleAndAlertText($data, $subsection_title) {
275
        if ($subsection_title) {
276
            $data['heading'] = $subsection_title;
277
        } else {
278
            $data['heading'] = $data['section_title'];
279
        }
280
281
        if ($subsection_title) {
282
            $data['intro'] = "$data[section_title]";
283
        } else {
284
            $data['intro'] = "";
285
        }
286
287
        if (array_key_exists('text_heading', $data['info'])) {
288
            // avoid having Clause 1 etc as the alert text search string on PBC pages as it's
289
            // almost certainly not what the person wants
290
            if ($this->major == 6) {
291
                $data['email_alert_text'] = $data['section_title'];
292
            } else {
293
                $data['email_alert_text'] = $data['info']['text_heading'];
294
            }
295
        } else {
296
            // The user has requested only part of a debate, so find a suitable title
297
            if ($subsection_title) {
298
                $data['intro'] = "Part of $data[section_title]";
299
            } else {
300
                $data['intro'] = "Part of the debate";
301
            }
302
            foreach ($data['rows'] as $row) {
303
                if ($row['htype'] == 10 || $row['htype'] == 11) {
304
                    $data['email_alert_text'] = $row['body'];
305
                    $data['full_debate_url'] = $row['listurl'];
306
                    break;
307
                }
308
            }
309
        }
310
        // strip a couple of common characters that result in encode junk in the
311
        // search string
312
        $data['email_alert_text'] = preg_replace('/(?:[:()\[\]]|&#\d+;)/', '', $data['email_alert_text']);
313
314
        return $data;
315
    }
316
317
    private function highlightSpeeches($data) {
318
        $SEARCHENGINE = null;
319
        if (isset($data['info']['searchstring']) && $data['info']['searchstring'] != '') {
320
            $SEARCHENGINE = new \SEARCHENGINE($data['info']['searchstring']);
321
        }
322
323
        // Before we print the body text we need to insert glossary links
324
        // and highlight search string words.
325
326
        $speeches = 0;
327
        $bodies = [];
328
        foreach ($data['rows'] as $row) {
329
            $htype = $row['htype'];
330
            if ($htype == 12 || $htype == 13 || $htype == 14) {
331
                $speeches++;
332
            }
333
            $body = $row['body'];
334
            $body = preg_replace('#<phrase class="honfriend" id="uk.org.publicwhip/member/(\d+)" name="([^"]*?)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?m=$1" title="Our page on $2 - \'$3\'">$4</a>', $body);
335
            $body = preg_replace('#<phrase class="honfriend" name="([^"]*?)" person_id="uk.org.publicwhip/person/(\d+)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?p=$2" title="Our page on $1 - \'$3\'">$4</a>', $body);
336
            $body = preg_replace_callback('#<phrase class="offrep" id="(.*?)/(\d+)-(\d+)-(\d+)\.(.*?)">(.*?)</phrase>#', function ($matches) {
337
                return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] . '">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
338
            }, $body);
339
            #$body = preg_replace('#<phrase class="offrep" id="((.*?)/(\d+)-(\d+)-(\d+)\.(.*?))">(.*?)</phrase>#e', "\"<a href='/search/?pop=1&amp;s=date:$3$4$5+column:$6+section:$2&amp;match=$1'>\" . str_replace('Official Report', 'Hansard', '$7') . '</a>'", $body);
340
            $bodies[] = $body;
341
        }
342
343
        if ($SEARCHENGINE) {
344
            // We have some search terms to highlight.
345
            twfy_debug_timestamp('Before highlight');
346
            $bodies = $SEARCHENGINE->highlight($bodies);
347
            twfy_debug_timestamp('After highlight');
348
        }
349
        // Do all this unless the glossary is turned off in the URL
350
        if (get_http_var('ug') != 1) {
351
            // And glossary phrases
352
            twfy_debug_timestamp('Before glossarise');
353
354
            $args['sort'] = "regexp_replace";
0 ignored issues
show
Comprehensibility Best Practice introduced by
$args was never initialized. Although not strictly required by PHP, it is generally a good practice to add $args = array(); before regardless.
Loading history...
355
            $GLOSSARY = new \GLOSSARY($args);
356
            $bodies = $GLOSSARY->glossarise($bodies, 1);
357
358
            twfy_debug_timestamp('After glossarise');
359
        }
360
361
        return [$bodies, $speeches];
362
    }
363
364
    private function annotateSpeeches($data, $bodies, $speeches) {
0 ignored issues
show
Unused Code introduced by
The parameter $speeches is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

364
    private function annotateSpeeches($data, $bodies, /** @scrutinizer ignore-unused */ $speeches) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
365
        global $THEUSER;
366
        $first_speech = null;
367
        $data['section_title'] = '';
368
        $subsection_title = '';
369
        $rows = count($data['rows']);
370
        for ($i = 0; $i < $rows; $i++) {
371
            $row = $data['rows'][$i];
372
            $htype = $row['htype'];
373
            // HPOS should be defined below if it's needed; otherwise default to 0
374
            $heading_hpos = 0;
375
            if ($htype == 10) {
376
                $data['section_title'] = $row['body'];
377
                $heading_hpos = $row['hpos'];
0 ignored issues
show
Unused Code introduced by
The assignment to $heading_hpos is dead and can be removed.
Loading history...
378
            } elseif ($htype == 11) {
379
                $subsection_title = $row['body'];
380
                $heading_hpos = $row['hpos'];
381
            } elseif ($htype == 12) {
382
                # Splitting out highlighting results back into individual bits
383
                $data['rows'][$i]['body'] = $bodies[$i];
384
            }
385
            if ($htype == 12 || $htype == 13 || $htype == 14) {
386
                if (!$first_speech) {
387
                    $first_speech = $data['rows'][$i];
388
                }
389
390
                # Voting links
391
                $data['rows'][$i]['voting_data'] = '';
392
                if (isset($row['votes'])) {
393
                    $data['rows'][$i]['voting_data'] = $this->generate_votes($row['votes'], $row['epobject_id'], $row['gid']);
0 ignored issues
show
Bug introduced by
The method generate_votes() does not exist on MySociety\TheyWorkForYou\SectionView\SectionView. It seems like you code against a sub-type of MySociety\TheyWorkForYou\SectionView\SectionView such as MySociety\TheyWorkForYou\SectionView\WransView. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

393
                    /** @scrutinizer ignore-call */ 
394
                    $data['rows'][$i]['voting_data'] = $this->generate_votes($row['votes'], $row['epobject_id'], $row['gid']);
Loading history...
394
                }
395
396
                # Annotation link
397
                if ($this->is_debate_section_page()) {
398
                    $data['rows'][$i]['commentteaser'] = $this->generate_commentteaser($row);
399
                }
400
401
                if (isset($row['mentions'])) {
402
                    $data['rows'][$i]['mentions'] = $this->get_question_mentions_html($row['mentions']);
403
                }
404
405
                if (array_key_exists('name', $data['rows'][$i]['speaker'])) {
406
                    $data['rows'][$i]['socialteaser'] = sprintf(
407
                        '%s on %s, at TheyWorkForYou',
408
                        ucfirst($data['rows'][$i]['speaker']['name']),
409
                        $data['section_title']
410
                    );
411
                } else {
412
                    $data['rows'][$i]['socialteaser'] = sprintf(
413
                        '%s on TheyWorkForYou',
414
                        $data['section_title']
415
                    );
416
                }
417
418
                $data['rows'][$i]['socialurl'] = sprintf(
419
                    'https://www.theyworkforyou.com%s',
420
                    $row['commentsurl']
421
                );
422
            }
423
        }
424
425
        return [$data, $first_speech, $subsection_title];
426
    }
427
428
    private function getCountryDetails() {
429
        $details = [
430
            1 =>  [
431
                'country' => 'UK',
432
                'assembly' => 'uk-commons',
433
                'location' => '&ndash; in the House of Commons',
434
            ],
435
            2 =>  [
436
                'country' => 'UK',
437
                'assembly' => 'uk-commons',
438
                'location' => '&ndash; in Westminster Hall',
439
            ],
440
            3 =>  [
441
                'country' => 'UK',
442
                'assembly' => 'uk-commons',
443
                'location' => 'written question &ndash; answered',
444
            ],
445
            4 =>  [
446
                'country' => 'UK',
447
                'assembly' => 'uk-commons',
448
                'location' => 'written statement &ndash; made',
449
            ],
450
            5 =>  [
451
                'country' => 'NORTHERN IRELAND',
452
                'assembly' => 'ni',
453
                'location' => '&ndash; in the Northern Ireland Assembly',
454
            ],
455
            6 =>  [
456
                'country' => 'UK',
457
                'assembly' => 'uk-commons',
458
                'location' => '&ndash; in a Public Bill Committee',
459
            ],
460
            7 =>  [
461
                'country' => 'SCOTLAND',
462
                'assembly' => 'scotland',
463
                'location' => '&ndash; in the Scottish Parliament',
464
            ],
465
            8 =>  [
466
                'country' => 'SCOTLAND',
467
                'assembly' => 'scotland',
468
                'location' => '&ndash; Scottish Parliament written question &ndash; answered',
469
            ],
470
            9 =>  [
471
                'country' => 'LONDON',
472
                'assembly' => 'london-assembly',
473
                'location' => 'Questions to the Mayor of London &ndash; answered',
474
            ],
475
            10 =>  [
476
                'country' => 'WALES',
477
                'assembly' => 'senedd',
478
                'location' => '&ndash; in the Senedd',
479
            ],
480
            11 =>  [
481
                'country' => 'WALES',
482
                'assembly' => 'senedd',
483
                'location' => '&ndash; Senedd Cymru',
484
            ],
485
            101 =>  [
486
                'country' => 'UK',
487
                'assembly' => 'uk-lords',
488
                'location' => '&ndash; in the House of Lords',
489
            ],
490
        ];
491
492
        $detail = $details[$this->major];
493
        return [$detail['country'], $detail['location'], $detail['assembly']];
494
    }
495
496
    private function majorToConsType() {
497
        $major_to_cons_type = [
498
            1 => 'WMC',
499
            2 => 'WMC',
500
            3 => 'WMC',
501
            4 => 'WMC',
502
            5 => 'NIE',
503
            6 => 'WMC',
504
            7 => 'SPC',
505
            8 => 'SPC',
506
            10 => 'WAC',
507
            11 => 'WAC',
508
            101 => '',
509
        ];
510
511
        return $major_to_cons_type[$this->major];
512
    }
513
514
    protected function display_front() {
515
        global $DATA, $this_page;
516
        $this_page = $this->page_base . 'front';
517
        $data = [];
518
        if ($this->index_template) {
519
            $data['template'] = $this->index_template;
520
        }
521
522
        $class = new $this->class();
523
        $content = [];
524
        $content['data'] = $this->front_content();
0 ignored issues
show
Bug introduced by
The method front_content() does not exist on MySociety\TheyWorkForYou\SectionView\SectionView. It seems like you code against a sub-type of said class. However, the method does not exist in MySociety\TheyWorkForYou\SectionView\DebatesView. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

524
        /** @scrutinizer ignore-call */ 
525
        $content['data'] = $this->front_content();
Loading history...
525
526
        $content['calendar'] = $class->display('calendar', ['months' => 1], 'none');
527
528
        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
529
            $content['rssurl'] = $rssurl;
530
        }
531
532
        $data['content'] = $content;
533
        return $this->addCommonData($data);
534
535
    }
536
537
    public function is_debate_section_page() {
538
        global $this_page;
539
        return ($this->major_data['type'] == 'debate' && $this->major_data['page_all'] == $this_page);
540
    }
541
542
    //$totalcomments, $comment, $commenturl
543
    public function generate_commentteaser($row) {
544
        // Returns HTML for the one fragment of comment and link for the sidebar.
545
        // $totalcomments is the number of comments this item has on it.
546
        // $comment is an array like:
547
        /* $comment = array (
548
            'comment_id' => 23,
549
            'user_id'    => 34,
550
            'body'        => 'Blah blah...',
551
            'posted'    => '2004-02-24 23:45:30',
552
            'username'    => 'phil'
553
            )
554
        */
555
        // $url is the URL of the item's page, which contains comments.
556
557
        if ($row['totalcomments'] == 0) {
558
            return;
559
        }
560
561
        //Add existing annotations
562
        $comment = $row['comment'];
563
564
        // If the comment is longer than the speech body, we want to trim it
565
        // to be the same length so they fit next to each other.
566
        // But the comment typeface is smaller, so we scale things slightly too...
567
        $targetsize = round(strlen($row['body']) * 0.6);
568
569
        $linktext = '';
570
        if ($targetsize > strlen($comment['body'])) {
571
            // This comment will fit in its entirety.
572
            $commentbody = $comment['body'];
573
574
            if ($row['totalcomments'] > 1) {
575
                $morecount = $row['totalcomments'] - 1;
576
                $plural = $morecount == 1 ? 'annotation' : 'annotations';
577
                $linktext = "Read $morecount more $plural";
578
            }
579
580
        } else {
581
            // This comment needs trimming.
582
            $commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
583
            if ($row['totalcomments'] > 1) {
584
                $morecount = $row['totalcomments'] - 1;
585
                $plural = $morecount == 1 ? 'annotation' : 'annotations';
586
                $linktext = "Continue reading (and $morecount more $plural)";
587
            } else {
588
                $linktext = 'Continue reading';
589
            }
590
        }
591
592
        return [
593
            'body' => prepare_comment_for_display($commentbody),
594
            'username' => _htmlentities($comment['username']),
595
            'linktext' => $linktext,
596
            'commentsurl' => $row['commentsurl'],
597
            'comment_id' => $comment['comment_id'],
598
        ];
599
    }
600
601
    protected function get_question_mentions_html($row_data) {
0 ignored issues
show
Unused Code introduced by
The parameter $row_data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

601
    protected function get_question_mentions_html(/** @scrutinizer ignore-unused */ $row_data) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
602
        throw new \Exception('get_question_mentions_html called from class with no implementation');
603
    }
604
605
    private function pageToSection() {
606
        $sections = [
607
            1 => 'debates',
608
            2 => 'whall',
609
            3 => 'wrans',
610
            4 => 'wms',
611
            5 => 'ni',
612
            6 => 'standing',
613
            7 => 'sp',
614
            8 => 'spwrans',
615
            9 => 'lmqs',
616
            10 => 'senedd',
617
            11 => 'senedd',
618
            101 => 'lords',
619
        ];
620
621
        return $sections[$this->major];
622
    }
623
624
}
625