Hansard::search()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MySociety\TheyWorkForYou;
4
5
/**
6
 * Hansard
7
 */
8
9
class Hansard extends \HANSARDLIST {
10
    /**
11
     * Search
12
     *
13
     * Performs a search of Hansard.
14
     *
15
     * @param string $searchstring The string to initialise SEARCHENGINE with.
16
     * @param array  $args         An array of arguments to restrict search results.
17
     *
18
     * @return array An array of search results.
19
     */
20
21
    public function search($searchstring, $args) {
0 ignored issues
show
Unused Code introduced by
The parameter $searchstring 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

21
    public function search(/** @scrutinizer ignore-unused */ $searchstring, $args) {

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...
22
23
        if (!defined('FRONT_END_SEARCH') || !FRONT_END_SEARCH) {
24
            throw new \Exception('FRONT_END_SEARCH is not defined or is false.');
25
        }
26
27
        // throw exceptions rather than emit PAGE->error
28
        $args['exceptions'] = true;
29
        $list = new \HANSARDLIST();
30
        return $list->display('search', $args, 'none');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $list->display('search', $args, 'none') could also return false which is incompatible with the documented return type array. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

Loading history...
31
32
    }
33
34
}
35