Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.512 |
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 | ':name' => $name |
||
33 | 1 | )); |
|
34 | 1 | if ($q1->rows <= 0) |
|
35 | 1 | return false; |
|
36 | |||
37 | $query = "select name from constituency where main_name and cons_id = '".$q1->field(0,'cons_id')."'"; |
||
38 | $q2 = $db->query($query); |
||
39 | if ($q2->rows <= 0) |
||
40 | return false; |
||
41 | |||
42 | return $q2->field(0, "name"); |
||
43 | } |
||
44 | |||
46 |