Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3.4098 |
Changes | 0 |
1 | <?php |
||
23 | 1 | public static function normaliseConstituencyName($name) { |
|
24 | |||
25 | 1 | $db = new \ParlDB; |
|
26 | |||
27 | // In case we still have an & lying around |
||
28 | 1 | $name = str_replace("&", "&", $name); |
|
29 | |||
30 | 1 | $query = "select cons_id from constituency where name like :name and from_date <= date(now()) and date(now()) <= to_date"; |
|
31 | 1 | $q1 = $db->query($query, array( |
|
32 | 1 | ':name' => $name |
|
33 | 1 | ))->first(); |
|
34 | 1 | if (!$q1) { |
|
35 | 1 | return false; |
|
36 | } |
||
37 | |||
38 | $query = "select name from constituency where main_name and cons_id = '" . $q1['cons_id'] . "'"; |
||
39 | $q2 = $db->query($query)->first(); |
||
40 | if (!$q2) { |
||
41 | return false; |
||
42 | } |
||
43 | |||
44 | return $q2['name']; |
||
45 | } |
||
48 |