Completed
Pull Request — master (#1459)
by Nick
09:53
created
classes/Search.php 2 patches
Switch Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -82,42 +82,42 @@
 block discarded – undo
82 82
     private function prettify_search_section($section) {
83 83
         $name = '';
84 84
         switch ($section) {
85
-        case 'wrans':
86
-            $name = 'Written Answers';
87
-            break;
88
-        case 'uk':
89
-            $name = 'All UK';
90
-            break;
91
-        case 'debates':
92
-            $name = 'House of Commons debates';
93
-            break;
94
-        case 'whall':
95
-            $name = 'Westminster Hall debates';
96
-            break;
97
-        case 'lords':
98
-            $name = 'House of Lords debates';
99
-            break;
100
-        case 'wms':
101
-            $name = 'Written ministerial statements';
102
-            break;
103
-        case 'standing':
104
-            $name = 'Bill Committees';
105
-            break;
106
-        case 'future':
107
-            $name = 'Future Business';
108
-            break;
109
-        case 'ni':
110
-            $name = 'Northern Ireland Assembly Debates';
111
-            break;
112
-        case 'scotland':
113
-            $name = 'All Scotland';
114
-            break;
115
-        case 'sp':
116
-            $name = 'Scottish Parliament Debates';
117
-            break;
118
-        case 'spwrans':
119
-            $name = 'Scottish Parliament Written answers';
120
-            break;
85
+            case 'wrans':
86
+                $name = 'Written Answers';
87
+                break;
88
+            case 'uk':
89
+                $name = 'All UK';
90
+                break;
91
+            case 'debates':
92
+                $name = 'House of Commons debates';
93
+                break;
94
+            case 'whall':
95
+                $name = 'Westminster Hall debates';
96
+                break;
97
+            case 'lords':
98
+                $name = 'House of Lords debates';
99
+                break;
100
+            case 'wms':
101
+                $name = 'Written ministerial statements';
102
+                break;
103
+            case 'standing':
104
+                $name = 'Bill Committees';
105
+                break;
106
+            case 'future':
107
+                $name = 'Future Business';
108
+                break;
109
+            case 'ni':
110
+                $name = 'Northern Ireland Assembly Debates';
111
+                break;
112
+            case 'scotland':
113
+                $name = 'All Scotland';
114
+                break;
115
+            case 'sp':
116
+                $name = 'Scottish Parliament Debates';
117
+                break;
118
+            case 'spwrans':
119
+                $name = 'Scottish Parliament Written answers';
120
+                break;
121 121
         }
122 122
 
123 123
         return $name;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         $this->searchstring = $argparser->construct_search_string();
20 20
         $this->searchkeyword = $argparser->searchkeyword;
21 21
 
22
-        if ( !$this->searchstring ) {
22
+        if (!$this->searchstring) {
23 23
             $data = $this->get_form_params($data);
24 24
             $data['searchstring'] = '';
25 25
             $data['template'] = 'search/results';
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 
29 29
         $this->searchstring = filter_user_input($this->searchstring, 'strict');
30 30
         $warnings = $this->validate_search_string();
31
-        if ( $warnings ) {
31
+        if ($warnings) {
32 32
             $data['warnings'] = $warnings;
33 33
             $data['template'] = 'search/results';
34 34
             $data['searchstring'] = $this->searchstring;
35 35
             $data = $this->get_form_params($data);
36 36
             return $data;
37 37
         } else {
38
-            if (get_http_var('o')=='p') {
38
+            if (get_http_var('o') == 'p') {
39 39
                 $search = new Search\ByUsage();
40 40
                 $data = $search->search($this->searchstring);
41 41
                 $data['template'] = 'search/by-person';
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $data['person_name'] = $MEMBER->full_name();
53 53
         }
54 54
 
55
-        if ( isset($data['info']['spelling_correction']) ) {
55
+        if (isset($data['info']['spelling_correction'])) {
56 56
             $data['info']['spelling_correction_display'] = $this->prettifySearchString($data['info']['spelling_correction']);
57 57
         }
58 58
 
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
         $data['search_keyword'] = $this->searchkeyword;
145 145
 
146 146
         $is_adv = false;
147
-        foreach ( array('to', 'from', 'person', 'section', 'column', 'phrase', 'exclude' ) as $var ) {
147
+        foreach (array('to', 'from', 'person', 'section', 'column', 'phrase', 'exclude') as $var) {
148 148
             $key = "search_$var";
149
-            $data[$key] = get_http_var( $var );
150
-            if ( $data[$key] ) {
149
+            $data[$key] = get_http_var($var);
150
+            if ($data[$key]) {
151 151
                 $is_adv = true;
152 152
             }
153 153
         }
154 154
 
155
-        if ( isset($data['search_section']) ) {
155
+        if (isset($data['search_section'])) {
156 156
             $data['search_section_pretty'] = $this->prettify_search_section($data['search_section']);
157 157
         }
158 158
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 
163 163
     private function set_wtt_options($data) {
164 164
         $data['wtt'] = '';
165
-        if ( $wtt = get_http_var('wtt') ) {
165
+        if ($wtt = get_http_var('wtt')) {
166 166
             $data['wtt'] = $wtt;
167
-            if ( $wtt == 2 && $pid = get_http_var('pid') ) {
167
+            if ($wtt == 2 && $pid = get_http_var('pid')) {
168 168
                 $data['pid'] = null;
169 169
                 try {
170 170
                     $lord = new Member(array('person_id' => $pid, 'house' => 2));
171
-                } catch ( MemberException $e ) {
171
+                } catch (MemberException $e) {
172 172
                     return $data;
173 173
                 }
174
-                if ( $lord->valid ) {
174
+                if ($lord->valid) {
175 175
                     $data['pid'] = $pid;
176 176
                     $data['wtt_lord_name'] = $lord->full_name();
177 177
                 }
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             $url->insert(array('q' => $value));
197 197
         }
198 198
 
199
-        if ( $params ) {
200
-            if ( get_http_var('house') ) {
199
+        if ($params) {
200
+            if (get_http_var('house')) {
201 201
                 $url->insert(array('house' => get_http_var('house')));
202 202
             }
203
-            if ( get_http_var('wtt') ) {
203
+            if (get_http_var('wtt')) {
204 204
                 $url->insert(array('wtt' => get_http_var('wtt')));
205 205
             }
206 206
         } else {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         global $DATA, $this_page;
215 215
 
216 216
         $pagetitle = '';
217
-        if ( isset($data['search_type']) && $data['search_type'] == 'person' ) {
217
+        if (isset($data['search_type']) && $data['search_type'] == 'person') {
218 218
             if (isset($data['wtt']) && $data['wtt'] > 0) {
219 219
                 $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
220 220
             } else {
Please login to merge, or discard this patch.
classes/Homepage.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
     }
49 49
 
50 50
     protected function getRegionalList() {
51
-        return NULL;
51
+        return null;
52 52
     }
53 53
 
54 54
     protected function getEditorialContent() {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
         $gid = $featured->get_gid();
58 58
         $gidCheck = new Gid($gid);
59 59
         $gid = $gidCheck->checkForRedirect();
60
-        if ( $gid ) {
60
+        if ($gid) {
61 61
             $title = $featured->get_title();
62 62
             $context = $featured->get_context();
63 63
             $related = $featured->get_related();
64 64
             $item = $this->getFeaturedDebate($gid, $title, $context, $related);
65 65
         } else {
66 66
             $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
67
-            if ( isset($item['data']) && count($item['data']) ) {
67
+            if (isset($item['data']) && count($item['data'])) {
68 68
                 $item = $item['data'][0];
69 69
                 $more_url = new Url('debates');
70 70
                 $item['more_url'] = $more_url->generate();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         $item['featured'] = true;
96 96
 
97 97
         $related_debates = array();
98
-        foreach ( $related as $related_gid ) {
99
-            if ( $related_gid ) {
98
+        foreach ($related as $related_gid) {
99
+            if ($related_gid) {
100 100
                 $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none');
101 101
                 $related_debates[] = $related_item['data'];
102 102
             }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 
122 122
         $recent_content = array();
123 123
 
124
-        foreach ( $this->recent_types as $class => $recent ) {
124
+        foreach ($this->recent_types as $class => $recent) {
125 125
             $class = "\\$class";
126 126
             $instance = new $class();
127 127
             $more_url = new Url($recent[1]);
128
-            if ( $recent[0] == 'recent_pbc_debates' ) {
129
-                $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') );
128
+            if ($recent[0] == 'recent_pbc_debates') {
129
+                $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none'));
130 130
             } else {
131 131
                 $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none');
132
-                if ( isset($content['data']) && count($content['data']) ) {
132
+                if (isset($content['data']) && count($content['data'])) {
133 133
                     $content = $content['data'][0];
134 134
                 } else {
135 135
                     $content = array();
136 136
                 }
137 137
             }
138
-            if ( $content ) {
138
+            if ($content) {
139 139
                 $content['more_url'] = $more_url->generate();
140 140
                 $content['desc'] = $recent[2];
141 141
                 $recent_content[] = $content;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             WHERE event_date >= :date
155 155
             AND deleted = 0
156 156
             ORDER BY event_date, chamber, pos",
157
-            array( ':date' => $date )
157
+            array(':date' => $date)
158 158
         );
159 159
 
160 160
         $data = array();
Please login to merge, or discard this patch.
classes/Utility/Hansard.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 class Hansard
12 12
 {
13 13
     public static function get_gid_from_url($url) {
14
-        $gid = NULL;
14
+        $gid = null;
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
18
-        if ( $query['id'] ) {
18
+        if ($query['id']) {
19 19
             if (strpos($parts['path'], 'lords') !== false) {
20 20
                 $gid = 'uk.org.publicwhip/lords/';
21 21
             } elseif (strpos($parts['path'], 'whall') !== false) {
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
     public static function gid_to_url($gid) {
33
-        if ( !$gid ) {
33
+        if (!$gid) {
34 34
             return '';
35 35
         }
36 36
         global $hansardmajors;
37 37
         $db = new \ParlDB();
38 38
 
39
-        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ))->first();
39
+        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid))->first();
40 40
         $url_gid = fix_gid_from_db($gid);
41 41
         $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q['major']]['page']);
42 42
         $url->insert(array('id' => $url_gid));
Please login to merge, or discard this patch.
classes/Utility/Gaze.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) {
26 26
             return gaze_get_country_from_ip($ip);
27 27
         } else {
28
-            return NULL;
28
+            return null;
29 29
         }
30 30
 
31 31
     }
Please login to merge, or discard this patch.
classes/Utility/Postcode.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug ("TIME", "postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
43 43
             return $return_value;
44 44
         }
45 45
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         if ($last_postcode == $postcode) {
41 41
             $return_value = $mp_only ? $last_postcode_value['WMC'] : $last_postcode_value;
42
-            twfy_debug ("TIME", "Postcode $postcode looked up last time, is " . ( is_array($return_value) ? implode(', ', $return_value) : $return_value ));
42
+            twfy_debug("TIME", "Postcode $postcode looked up last time, is " . (is_array($return_value) ? implode(', ', $return_value) : $return_value));
43 43
             return $return_value;
44 44
         }
45 45
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
             $name = $q['name'];
76 76
             if (self::postcodeIsScottish($postcode)) {
77 77
                 $name = explode('|', $name);
78
-                if (count($name)==3)
78
+                if (count($name) == 3)
79 79
                     return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80 80
             } elseif (self::postcodeIsNi($postcode)) {
81 81
                 $name = explode('|', $name);
82
-                if (count($name)==2)
82
+                if (count($name) == 2)
83 83
                     return array('WMC' => $name[0], 'NIE' => $name[1]);
84 84
             } else {
85 85
                 return array('WMC' => $name);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         $r = json_decode($file, true);
115 115
         if (!$r) {
116
-            trigger_error("Postcode database is not working. Content:\n".$file.", request: ". $filename, E_USER_WARNING);
116
+            trigger_error("Postcode database is not working. Content:\n" . $file . ", request: " . $filename, E_USER_WARNING);
117 117
             return '';
118 118
         }
119 119
         if (isset($r['error']) || !isset($r['areas'])) {
@@ -179,29 +179,29 @@  discard block
 block discarded – undo
179 179
         if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180 180
             return true;
181 181
 
182
-        if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
182
+        if ($m[1] == 'DG') {
183
+            if ($m[2] == 16 && $m[3] == 5 && in_array($m[4], array('HT', 'HU', 'HZ', 'JA', 'JB'))) return false; # A few postcodes in England
184 184
             return true;
185 185
         }
186 186
 
187 187
         # Damn postcodes crossing country boundaries
188
-        if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
-            if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
188
+        if ($m[1] == 'TD') {
189
+            if ($m[2] != 15 && $m[2] != 12 && $m[2] != 9) return true; # TD1-8, 10-11, 13-14 all in Scotland
190
+            if ($m[2] == 9) {
191
+                if ($m[3] != 0) return true; # TD9 1-9 all in Scotland
192
+                if (!in_array($m[4], array('TJ', 'TP', 'TR', 'TS', 'TT', 'TU', 'TW'))) return true; # Nearly all of TD9 0 in Scotland
193 193
             }
194 194
             $m[5] = substr($m[4], 0, 1);
195
-            if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
195
+            if ($m[2] == 12) { # $m[3] will be 4 currently.
196
+                if ($m[4] == 'XE') return true;
197
+                if (in_array($m[5], array('A', 'B', 'D', 'E', 'H', 'J', 'L', 'N', 'W', 'Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 198
             }
199 199
             # TD15 is mostly England
200
-            if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
200
+            if ($m[2] == 15) {
201
+                if ($m[3] != 1) return false; # TD15 2 and 9 are in England
202
+                if (in_array($m[4], array('BT', 'SU', 'SZ', 'UF', 'UG', 'UH', 'UJ', 'UL', 'US', 'UZ', 'WY', 'WZ'))) return true;
203
+                if ($m[5] == 'T' && $m[4] != 'TA' && $m[4] != 'TB') return true; # Most of TD15 1T* in Scotland
204
+                if ($m[5] == 'X' && $m[4] != 'XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
205 205
             }
206 206
         }
207 207
 
Please login to merge, or discard this patch.
Braces   +61 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
             $ret = self::postcodeFetchFromMapit($postcode);
53 53
         }
54 54
 
55
-        if (is_string($ret)) return $ret;
55
+        if (is_string($ret)) {
56
+            return $ret;
57
+        }
56 58
 
57 59
         $last_postcode = $postcode;
58 60
         $last_postcode_value = $ret;
@@ -75,12 +77,14 @@  discard block
 block discarded – undo
75 77
             $name = $q['name'];
76 78
             if (self::postcodeIsScottish($postcode)) {
77 79
                 $name = explode('|', $name);
78
-                if (count($name)==3)
79
-                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
80
+                if (count($name)==3) {
81
+                                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
82
+                }
80 83
             } elseif (self::postcodeIsNi($postcode)) {
81 84
                 $name = explode('|', $name);
82
-                if (count($name)==2)
83
-                    return array('WMC' => $name[0], 'NIE' => $name[1]);
85
+                if (count($name)==2) {
86
+                                    return array('WMC' => $name[0], 'NIE' => $name[1]);
87
+                }
84 88
             } else {
85 89
                 return array('WMC' => $name);
86 90
             }
@@ -121,8 +125,9 @@  discard block
 block discarded – undo
121 125
         }
122 126
         $areas = array();
123 127
         foreach ($r['areas'] as $row) {
124
-            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE')))
125
-                $areas[$row['type']] = $row['name'];
128
+            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE'))) {
129
+                            $areas[$row['type']] = $row['name'];
130
+            }
126 131
         }
127 132
 
128 133
         if (!isset($areas['WMC'])) {
@@ -172,36 +177,67 @@  discard block
 block discarded – undo
172 177
      */
173 178
 
174 179
     public static function postcodeIsScottish($pc) {
175
-        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m))
176
-            return false;
180
+        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m)) {
181
+                    return false;
182
+        }
177 183
 
178 184
         # Check for Scottish postal areas
179
-        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE')))
180
-            return true;
185
+        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE'))) {
186
+                    return true;
187
+        }
181 188
 
182 189
         if ($m[1]=='DG') {
183
-            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) return false; # A few postcodes in England
190
+            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) {
191
+                return false;
192
+            }
193
+            # A few postcodes in England
184 194
             return true;
185 195
         }
186 196
 
187 197
         # Damn postcodes crossing country boundaries
188 198
         if ($m[1]=='TD') {
189
-            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) return true; # TD1-8, 10-11, 13-14 all in Scotland
199
+            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) {
200
+                return true;
201
+            }
202
+            # TD1-8, 10-11, 13-14 all in Scotland
190 203
             if ($m[2]==9) {
191
-                if ($m[3]!=0) return true; # TD9 1-9 all in Scotland
192
-                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) return true; # Nearly all of TD9 0 in Scotland
204
+                if ($m[3]!=0) {
205
+                    return true;
206
+                }
207
+                # TD9 1-9 all in Scotland
208
+                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) {
209
+                    return true;
210
+                }
211
+                # Nearly all of TD9 0 in Scotland
193 212
             }
194 213
             $m[5] = substr($m[4], 0, 1);
195
-            if ($m[2]==12) { # $m[3] will be 4 currently.
196
-                if ($m[4]=='XE') return true;
197
-                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) return true; # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
214
+            if ($m[2]==12) {
215
+# $m[3] will be 4 currently.
216
+                if ($m[4]=='XE') {
217
+                    return true;
218
+                }
219
+                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) {
220
+                    return true;
221
+                }
222
+                # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 223
             }
199 224
             # TD15 is mostly England
200 225
             if ($m[2]==15) {
201
-                if ($m[3]!=1) return false; # TD15 2 and 9 are in England
202
-                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) return true;
203
-                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') return true; # Most of TD15 1T* in Scotland
204
-                if ($m[5]=='X' && $m[4]!='XX') return true; # TD15 1XX in England, rest of TD15 1X* in Scotland
226
+                if ($m[3]!=1) {
227
+                    return false;
228
+                }
229
+                # TD15 2 and 9 are in England
230
+                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) {
231
+                    return true;
232
+                }
233
+                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') {
234
+                    return true;
235
+                }
236
+                # Most of TD15 1T* in Scotland
237
+                if ($m[5]=='X' && $m[4]!='XX') {
238
+                    return true;
239
+                }
240
+                # TD15 1XX in England, rest of TD15 1X* in Scotland
205 241
             }
206 242
         }
207 243
 
@@ -215,8 +251,9 @@  discard block
 block discarded – undo
215 251
 
216 252
     public static function postcodeIsNi($pc) {
217 253
         $prefix = substr(self::canonicalisePostcode($pc), 0, 2);
218
-        if ($prefix == 'BT')
219
-            return true;
254
+        if ($prefix == 'BT') {
255
+                    return true;
256
+        }
220 257
         return false;
221 258
     }
222 259
 
Please login to merge, or discard this patch.
classes/SPHomepage.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     protected function getCalendarData() {
41
-        return NULL;
41
+        return null;
42 42
     }
43 43
 
44 44
 
Please login to merge, or discard this patch.
classes/Party.php 3 patches
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $both = 1;
220 220
         $agree = 10;
221 221
 
222
-        if ( stripos($vote, '3') !== FALSE ) {
222
+        if ( stripos($vote, '3') !== false ) {
223 223
             $agree = 50;
224 224
             $absent = 25;
225 225
             $both = 25;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             'both' => $both
231 231
         );
232 232
 
233
-        if ( stripos($vote, 'aye') !== FALSE ) {
233
+        if ( stripos($vote, 'aye') !== false ) {
234 234
             $scores['aye'] = $agree;
235 235
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
236
+        } else if ( stripos($vote, 'no') !== false ) {
237 237
             $scores['no'] = $agree;
238 238
             $scores['aye'] = 0;
239 239
         } else {
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -144,9 +144,15 @@
 block discarded – undo
144 144
             $num_votes = 0;
145 145
             foreach ($votes as $vote) {
146 146
                 $vote_dir = $vote['vote'];
147
-                if ( $vote_dir == '' ) continue;
148
-                if ( $vote_dir == 'tellno' ) $vote_dir = 'no';
149
-                if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye';
147
+                if ( $vote_dir == '' ) {
148
+                    continue;
149
+                }
150
+                if ( $vote_dir == 'tellno' ) {
151
+                    $vote_dir = 'no';
152
+                }
153
+                if ( $vote_dir == 'tellaye' ) {
154
+                    $vote_dir = 'aye';
155
+                }
150 156
 
151 157
                 $num_votes += $vote['num_votes'];
152 158
                 $score += ($vote['num_votes'] * $weights[$vote_dir]);
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __construct($name) {
21 21
         // treat Labour and Labour/Co-operative the same as that's how
22 22
         // people view them and it'll confuse the results otherwise
23
-        if ( $name == 'Labour/Co-operative' ) {
23
+        if ($name == 'Labour/Co-operative') {
24 24
             $name = 'Labour';
25 25
         }
26 26
         $this->name = $name;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
             $score = $position['score'];
75 75
             $score_desc = score_to_strongly($score);
76 76
 
77
-            if ( $want_score ) {
78
-                return array( $score_desc, $score);
77
+            if ($want_score) {
78
+                return array($score_desc, $score);
79 79
             } else {
80 80
                 return $score_desc;
81 81
             }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             ':party' => $this->name
115 115
         );
116 116
 
117
-        if ( $this->name == 'Labour' ) {
117
+        if ($this->name == 'Labour') {
118 118
             $party_where = '( party = :party OR party = :party2 )';
119 119
             $params = array(
120 120
                 ':party' => $this->name,
@@ -144,40 +144,40 @@  discard block
 block discarded – undo
144 144
             $num_votes = 0;
145 145
             foreach ($votes as $vote) {
146 146
                 $vote_dir = $vote['vote'];
147
-                if ( $vote_dir == '' ) continue;
148
-                if ( $vote_dir == 'tellno' ) $vote_dir = 'no';
149
-                if ( $vote_dir == 'tellaye' ) $vote_dir = 'aye';
147
+                if ($vote_dir == '') continue;
148
+                if ($vote_dir == 'tellno') $vote_dir = 'no';
149
+                if ($vote_dir == 'tellaye') $vote_dir = 'aye';
150 150
 
151 151
                 $num_votes += $vote['num_votes'];
152 152
                 $score += ($vote['num_votes'] * $weights[$vote_dir]);
153 153
             }
154 154
 
155 155
             $total_votes += $num_votes;
156
-            $max_score += $num_votes * max( array_values( $weights ) );
156
+            $max_score += $num_votes * max(array_values($weights));
157 157
         }
158 158
 
159
-        if ( $total_votes == 0 ) {
159
+        if ($total_votes == 0) {
160 160
             return null;
161 161
         }
162 162
 
163 163
         // this implies that all the divisions in the policy have a policy
164 164
         // position of absent so we set weight to -1 to indicate we can't
165 165
         // really say what the parties position is.
166
-        if ( $max_score == 0 ) {
166
+        if ($max_score == 0) {
167 167
             $weight = -1;
168 168
         } else {
169
-            $weight = 1 - ( $score/$max_score );
169
+            $weight = 1 - ($score / $max_score);
170 170
         }
171 171
         $score_desc = score_to_strongly($weight);
172 172
 
173
-        if ( $want_score ) {
174
-            return array( $score_desc, $weight);
173
+        if ($want_score) {
174
+            return array($score_desc, $weight);
175 175
         } else {
176 176
             return $score_desc;
177 177
         }
178 178
     }
179 179
 
180
-    public function cache_position( $position ) {
180
+    public function cache_position($position) {
181 181
         $this->db->query(
182 182
             "REPLACE INTO partypolicy
183 183
                 (party, house, policy_id, score)
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
             return $positions;
198 198
         }
199 199
 
200
-        foreach ( $policies->getPolicies() as $policy_id => $policy_text ) {
201
-            list( $position, $score ) = $this->$method($policy_id, true);
202
-            if ( $position === null ) {
200
+        foreach ($policies->getPolicies() as $policy_id => $policy_text) {
201
+            list($position, $score) = $this->$method($policy_id, true);
202
+            if ($position === null) {
203 203
                 continue;
204 204
             }
205 205
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $both = 1;
220 220
         $agree = 10;
221 221
 
222
-        if ( stripos($vote, '3') !== FALSE ) {
222
+        if (stripos($vote, '3') !== FALSE) {
223 223
             $agree = 50;
224 224
             $absent = 25;
225 225
             $both = 25;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             'both' => $both
231 231
         );
232 232
 
233
-        if ( stripos($vote, 'aye') !== FALSE ) {
233
+        if (stripos($vote, 'aye') !== FALSE) {
234 234
             $scores['aye'] = $agree;
235 235
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
236
+        } else if (stripos($vote, 'no') !== FALSE) {
237 237
             $scores['no'] = $agree;
238 238
             $scores['aye'] = 0;
239 239
         } else {
Please login to merge, or discard this patch.
classes/AlertView.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     protected $db;
12 12
     protected $alert;
13 13
 
14
-    public function __construct($THEUSER = NULL) {
14
+    public function __construct($THEUSER = null) {
15 15
         $this->user = $THEUSER;
16 16
         $this->db = new \ParlDB;
17 17
         $this->alert = new \ALERT;
Please login to merge, or discard this patch.
classes/Topic.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      *
29 29
      */
30 30
 
31
-    public function __construct($data = NULL)
31
+    public function __construct($data = null)
32 32
     {
33 33
         $this->db = new \ParlDB;
34 34
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function sctitle() {
55 55
         $title = $this->title;
56
-        if (strpos($title, 'The ') === 0 ) {
56
+        if (strpos($title, 'The ') === 0) {
57 57
             $title = lcfirst($title);
58 58
         }
59 59
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             );
243 243
         } else {
244 244
             foreach ($sets as $set) {
245
-                if ($set == '' ) {
245
+                if ($set == '') {
246 246
                     continue;
247 247
                 }
248 248
                 $q = $this->db->query(
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             );
286 286
         } else {
287 287
             foreach ($policies as $policy) {
288
-                if ($policy == '' ) {
288
+                if ($policy == '') {
289 289
                     continue;
290 290
                 }
291 291
                 $q = $this->db->query(
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $this->db = new \ParlDB;
34 34
 
35 35
         if (is_null($data)) {
36
-          return;
36
+            return;
37 37
         }
38 38
 
39 39
         $this->id = $data['id'];
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
     private function _getContentIDs() {
126 126
         $q = $this->db->query(
127
-          "SELECT body, gid, ep.epobject_id FROM epobject ep
127
+            "SELECT body, gid, ep.epobject_id FROM epobject ep
128 128
            JOIN hansard h on ep.epobject_id = h.epobject_id
129 129
            JOIN topic_epobjects te on te.epobject_id = ep.epobject_id
130 130
            WHERE topic_key = :topic_key",
@@ -178,24 +178,24 @@  discard block
 block discarded – undo
178 178
 
179 179
     public function addContent($gid) {
180 180
         $q = $this->db->query(
181
-          "SELECT epobject_id FROM hansard WHERE gid = :gid",
182
-          array(
181
+            "SELECT epobject_id FROM hansard WHERE gid = :gid",
182
+            array(
183 183
             ":gid" => $gid
184
-          )
184
+            )
185 185
         )->first();
186 186
 
187 187
         if (!$q) {
188
-          return false;
188
+            return false;
189 189
         }
190 190
 
191 191
         $epobject_id = $q['epobject_id'];
192 192
 
193 193
         $q = $this->db->query(
194
-          "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)",
195
-          array(
194
+            "INSERT INTO topic_epobjects (topic_key, epobject_id) VALUES (:topic, :ep_id)",
195
+            array(
196 196
             ":topic" => $this->id,
197 197
             ":ep_id" => $epobject_id
198
-          )
198
+            )
199 199
         );
200 200
 
201 201
         return $q->success();
@@ -203,23 +203,23 @@  discard block
 block discarded – undo
203 203
 
204 204
     public function deleteContent($id) {
205 205
         $q = $this->db->query(
206
-          "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id",
207
-          array(
206
+            "DELETE FROM topic_epobjects WHERE topic_key = :topic AND epobject_id = :ep_id",
207
+            array(
208 208
             ":topic" => $this->id,
209 209
             ":ep_id" => $id
210
-          )
210
+            )
211 211
         );
212 212
 
213 213
         return $q->success();
214 214
     }
215 215
 
216 216
     public function getPolicySets() {
217
-      $q = $this->db->query(
217
+        $q = $this->db->query(
218 218
         "SELECT policyset FROM topic_policysets WHERE topic_key = :key",
219 219
         array(
220
-          ':key' => $this->id
220
+            ':key' => $this->id
221 221
         )
222
-      );
222
+        );
223 223
 
224 224
         $sets = array();
225 225
         foreach ($q as $row) {
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
     }
257 257
 
258 258
     public function getPolicies() {
259
-      $q = $this->db->query(
259
+        $q = $this->db->query(
260 260
         'SELECT policy_id FROM topic_policies WHERE topic_key = :key',
261 261
         array(
262
-          ':key' => $this->id
262
+            ':key' => $this->id
263 263
         )
264
-      );
264
+        );
265 265
 
266 266
         $policies = array();
267 267
         foreach ($q as $row) {
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
     public function save() {
314 314
         $q = $this->db->query(
315
-          "REPLACE INTO topics
315
+            "REPLACE INTO topics
316 316
           (id, title, slug, description, search_string, front_page, image)
317 317
           VALUES
318 318
           (:id, :title, :slug, :description, :search_string, :front_page, :image)",
Please login to merge, or discard this patch.