Failed Conditions
Pull Request — master (#1325)
by Nick
26:10 queued 21:10
created
tests/TWFY_Database_TestCase.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      */
16 16
     public function getConnection()
17 17
     {
18
-        $dsn = 'mysql:host=' . OPTION_TWFY_DB_HOST . ' ;dbname=' . OPTION_TWFY_DB_NAME . ';charset=utf8';
18
+        $dsn = 'mysql:host='.OPTION_TWFY_DB_HOST.' ;dbname='.OPTION_TWFY_DB_NAME.';charset=utf8';
19 19
         $username = OPTION_TWFY_DB_USER;
20 20
         $password = OPTION_TWFY_DB_PASS;
21 21
         $pdo = new PDO($dsn, $username, $password);
Please login to merge, or discard this 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
 
26 26
     public function tearDown()
27 27
     {
28
-        $this->db = NULL;
28
+        $this->db = null;
29 29
 
30 30
         parent::tearDown();
31 31
     }
Please login to merge, or discard this patch.
classes/Renderer.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -84,12 +84,12 @@
 block discarded – undo
84 84
         // Require the templates and output
85 85
 
86 86
         if ($template_only) {
87
-          require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
87
+            require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
88 88
         } else {
89
-          header('Content-Type: text/html; charset=utf-8');
90
-          require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
91
-          require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
92
-          require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php';
89
+            header('Content-Type: text/html; charset=utf-8');
90
+            require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
91
+            require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
92
+            require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php';
93 93
         }
94 94
     }
95 95
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $user = new Renderer\User();
44 44
         $data = array_merge($user->data, $data);
45 45
 
46
-        if ( isset($page_errors) ) {
46
+        if (isset($page_errors)) {
47 47
             $data['page_errors'] = $page_errors;
48 48
         }
49 49
 
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
         // Require the templates and output
85 85
 
86 86
         if ($template_only) {
87
-          require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
87
+          require_once INCLUDESPATH.'easyparliament/templates/html/'.$template.'.php';
88 88
         } else {
89 89
           header('Content-Type: text/html; charset=utf-8');
90
-          require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
91
-          require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
92
-          require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php';
90
+          require_once INCLUDESPATH.'easyparliament/templates/html/header.php';
91
+          require_once INCLUDESPATH.'easyparliament/templates/html/'.$template.'.php';
92
+          require_once INCLUDESPATH.'easyparliament/templates/html/footer.php';
93 93
         }
94 94
     }
95 95
 
96 96
     private static function addCommonURLs($data) {
97 97
         $urls = array();
98
-        if ( isset($data['urls']) ) {
98
+        if (isset($data['urls'])) {
99 99
             $urls = $data['urls'];
100 100
         }
101 101
 
102 102
         $common_urls = array('search', 'alert');
103 103
 
104
-        foreach ( $common_urls as $path ) {
105
-            if (!isset($urls[$path]) ) {
104
+        foreach ($common_urls as $path) {
105
+            if (!isset($urls[$path])) {
106 106
                 $url = new \URL($path);
107 107
                 $urls[$path] = $url->generate();
108 108
             }
Please login to merge, or discard this patch.
classes/AlertView/Simple.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
     public function display() {
8 8
         $data = array();
9 9
         $data['recent_election'] = false;
10
-        if ( $this->user->loggedin() ) {
10
+        if ($this->user->loggedin()) {
11 11
             $data['user_signed_in'] = true;
12 12
         }
13 13
 
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
             $data['postcode'] = get_http_var('postcode');
18 18
 
19 19
             $result = $this->createAlertForPostCode($data['email'], $data['postcode']);
20
-            $data = array_merge( $data, $result );
20
+            $data = array_merge($data, $result);
21 21
         } elseif (get_http_var('update')) {
22 22
             $result = $this->getNewMP(get_http_var('update'));
23
-            $data = array_merge( $data, $result );
23
+            $data = array_merge($data, $result);
24 24
         } elseif (get_http_var('update-alert')) {
25
-            $success = $this->replaceAlert( get_http_var('confirmation') );
25
+            $success = $this->replaceAlert(get_http_var('confirmation'));
26 26
             $data['confirmation_received'] = $success;
27 27
         } elseif (get_http_var('confirmed')) {
28
-            $success = $this->confirmAlert( get_http_var('confirmed') );
28
+            $success = $this->confirmAlert(get_http_var('confirmed'));
29 29
             $data['confirmation_received'] = $success;
30 30
         } else {
31 31
             $data['email'] = $this->user->email() ? $this->user->email() : '';
32 32
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 33
 
34
-            if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) {
34
+            if ($this->isEmailSignedUpForPostCode($data['email'], $data['postcode'])) {
35 35
                 $data['already_signed_up'] = True;
36 36
                 $mp = $this->getPersonFromPostcode($data['postcode']);
37 37
                 $data['mp_name'] = $mp->full_name();
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
     }
67 67
 
68 68
     private function createAlertForPostCode($email, $postcode) {
69
-        if ( !$this->validateDetails($email, $postcode) ) {
69
+        if (!$this->validateDetails($email, $postcode)) {
70 70
             return array('invalid-postcode-or-email' => True);
71 71
         }
72 72
 
73 73
         try {
74 74
             $person = $this->getPersonFromPostcode($postcode);
75
-        } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
75
+        } catch (\MySociety\TheyWorkForYou\MemberException $e) {
76 76
             return array('bad-constituency' => True);
77 77
         }
78 78
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             'email' => $email,
81 81
             'pid' => $person->person_id,
82 82
             'pc' => $postcode,
83
-            'confirm_base' => 'https://' . DOMAIN . '/alert/by-postcode?confirmed=',
83
+            'confirm_base' => 'https://'.DOMAIN.'/alert/by-postcode?confirmed=',
84 84
         );
85 85
 
86 86
         $data = array();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         switch ($result) {
91 91
             case self::ALERT_EXISTS:
92
-                if ( $not_logged_in ) {
92
+                if ($not_logged_in) {
93 93
                     // no logged in user so send them an email to let them
94 94
                     // know someone tried to create an alert
95 95
                     $this->alert->send_already_signedup_email($details);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $data['error'] = True;
103 103
                 break;
104 104
             default: // alert created
105
-                if ( $not_logged_in ) {
105
+                if ($not_logged_in) {
106 106
                     $data['confirmation_sent'] = True;
107 107
                 } else {
108 108
                     $data['signedup_no_confirm'] = True;
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
         $existing = $this->alert->fetch_by_token($confirmation);
117 117
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
118 118
         $old_mp_id = $matches[1];
119
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $old_mp_id ) );
120
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
119
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $old_mp_id));
120
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
121 121
 
122 122
         $q = $this->db->query(
123 123
             "SELECT alert_id, criteria, registrationtoken FROM alerts
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
              AND deleted = 0",
128 128
             array(
129 129
                 ':email' => $existing['email'],
130
-                ':criteria' => '%speaker:' . $old_mp_id . '%'
130
+                ':criteria' => '%speaker:'.$old_mp_id.'%'
131 131
             )
132 132
         );
133 133
 
134
-        for ( $i = 0; $i < $q->rows; $i++ ) {
134
+        for ($i = 0; $i < $q->rows; $i++) {
135 135
             // need to reset this otherwise delete does not work
136 136
             $this->alert->token_checked = null;
137 137
             $other_criteria = trim(preg_replace('/speaker:\d+/', '', $q->field($i, 'criteria')));
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
                 'pid' => $new_mp->person_id,
142 142
                 'pc' => '',
143 143
             );
144
-            if ( $other_criteria ) {
144
+            if ($other_criteria) {
145 145
                 $details['keyword'] = $other_criteria;
146 146
             }
147 147
 
148
-            $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken'));
148
+            $this->alert->delete($q->field($i, 'alert_id').'::'.$q->field($i, 'registrationtoken'));
149 149
             $this->alert->add($details, False);
150 150
         }
151 151
 
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
     private function isEmailSignedUpForPostCode($email, $postcode) {
159 159
         $is_signed_up = false;
160 160
 
161
-        if ( $email && $postcode ) {
161
+        if ($email && $postcode) {
162 162
             try {
163 163
                 $person = $this->getPersonFromPostcode($postcode);
164 164
                 $is_signed_up = $this->alert->fetch_by_mp($email, $person->person_id);
165
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
165
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
166 166
                 $is_signed_up = false;
167 167
             }
168 168
         }
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         preg_match('/speaker:(\d+)/', $existing['criteria'], $matches);
179 179
         $criteria = $matches[1];
180 180
 
181
-        $old_mp = new \MySociety\TheyWorkForYou\Member(array( 'person_id' => $criteria ) );
182
-        $new_mp = new \MySociety\TheyWorkForYou\Member(array( 'constituency' => $old_mp->constituency, 'house' => 1 ));
181
+        $old_mp = new \MySociety\TheyWorkForYou\Member(array('person_id' => $criteria));
182
+        $new_mp = new \MySociety\TheyWorkForYou\Member(array('constituency' => $old_mp->constituency, 'house' => 1));
183 183
 
184
-        if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) {
184
+        if ($this->alert->fetch_by_mp($existing['email'], $new_mp->person_id)) {
185 185
             $data = array(
186 186
                 'already_signed_up' => True,
187 187
                 'old_mp' => $old_mp->full_name(),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $data['postcode'] = $this->user->postcode_is_set() ? $this->user->postcode() : '';
33 33
 
34 34
             if ( $this->isEmailSignedUpForPostCode( $data['email'], $data['postcode'] ) ) {
35
-                $data['already_signed_up'] = True;
35
+                $data['already_signed_up'] = true;
36 36
                 $mp = $this->getPersonFromPostcode($data['postcode']);
37 37
                 $data['mp_name'] = $mp->full_name();
38 38
             }
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 
68 68
     private function createAlertForPostCode($email, $postcode) {
69 69
         if ( !$this->validateDetails($email, $postcode) ) {
70
-            return array('invalid-postcode-or-email' => True);
70
+            return array('invalid-postcode-or-email' => true);
71 71
         }
72 72
 
73 73
         try {
74 74
             $person = $this->getPersonFromPostcode($postcode);
75 75
         } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
76
-            return array('bad-constituency' => True);
76
+            return array('bad-constituency' => true);
77 77
         }
78 78
 
79 79
         $details = array(
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
                     // no logged in user so send them an email to let them
94 94
                     // know someone tried to create an alert
95 95
                     $this->alert->send_already_signedup_email($details);
96
-                    $data['confirmation_sent'] = True;
96
+                    $data['confirmation_sent'] = true;
97 97
                 } else {
98
-                    $data['already_signed_up'] = True;
98
+                    $data['already_signed_up'] = true;
99 99
                 }
100 100
                 break;
101 101
             case self::CREATE_FAILED:
102
-                $data['error'] = True;
102
+                $data['error'] = true;
103 103
                 break;
104 104
             default: // alert created
105 105
                 if ( $not_logged_in ) {
106
-                    $data['confirmation_sent'] = True;
106
+                    $data['confirmation_sent'] = true;
107 107
                 } else {
108
-                    $data['signedup_no_confirm'] = True;
108
+                    $data['signedup_no_confirm'] = true;
109 109
                 }
110 110
         }
111 111
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
             }
147 147
 
148 148
             $this->alert->delete($q->field($i, 'alert_id') . '::' . $q->field($i ,'registrationtoken'));
149
-            $this->alert->add($details, False);
149
+            $this->alert->add($details, false);
150 150
         }
151 151
 
152 152
         return array(
153
-            'signedup_no_confirm' => True,
153
+            'signedup_no_confirm' => true,
154 154
             'new_mp' => $new_mp->full_name(),
155 155
         );
156 156
     }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
         if ( $this->alert->fetch_by_mp( $existing['email'], $new_mp->person_id) ) {
185 185
             $data = array(
186
-                'already_signed_up' => True,
186
+                'already_signed_up' => true,
187 187
                 'old_mp' => $old_mp->full_name(),
188 188
                 'mp_name' => $new_mp->full_name(),
189 189
             );
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             );
195 195
         }
196 196
 
197
-        $data['update'] = True;
197
+        $data['update'] = true;
198 198
         $data['confirmation'] = $confirmation;
199 199
 
200 200
         return $data;
Please login to merge, or discard this patch.
classes/AlertView/Standard.php 3 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 namespace MySociety\TheyWorkForYou\AlertView;
4 4
 
5 5
 include_once '../../../www/includes/easyparliament/init.php';
6
-include_once INCLUDESPATH . "easyparliament/people.php";
7
-include_once INCLUDESPATH . "easyparliament/member.php";
8
-include_once INCLUDESPATH . "easyparliament/searchengine.php";
9
-include_once INCLUDESPATH . '../../commonlib/phplib/auth.php';
10
-include_once INCLUDESPATH . '../../commonlib/phplib/crosssell.php';
6
+include_once INCLUDESPATH."easyparliament/people.php";
7
+include_once INCLUDESPATH."easyparliament/member.php";
8
+include_once INCLUDESPATH."easyparliament/searchengine.php";
9
+include_once INCLUDESPATH.'../../commonlib/phplib/auth.php';
10
+include_once INCLUDESPATH.'../../commonlib/phplib/crosssell.php';
11 11
 
12 12
 class Standard extends \MySociety\TheyWorkForYou\AlertView {
13 13
     public $data;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         $se = new \SEARCHENGINE($text);
141 141
         if (!$se->valid) {
142
-            $errors['alertsearch'] = 'That search appears to be invalid - ' . $se->error . ' - please check and try again.';
142
+            $errors['alertsearch'] = 'That search appears to be invalid - '.$se->error.' - please check and try again.';
143 143
         }
144 144
 
145 145
         if (strlen($text) > 255) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 try {
180 180
                     $MEMBER = new \MEMBER(array('constituency'=>$constituency, 'house' => 1));
181 181
                     $cons[$constituency] = $MEMBER;
182
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
182
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
183 183
                     // do nothing
184 184
                 }
185 185
             }
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 
200 200
         // If this goes well, the alert will be added to the database and a confirmation email
201 201
         // will be sent to them.
202
-        $success = $this->alert->add( $this->data, $confirm );
202
+        $success = $this->alert->add($this->data, $confirm);
203 203
 
204
-        if ($success>0 && !$confirm) {
204
+        if ($success > 0 && !$confirm) {
205 205
             $result = 'alert-added';
206
-        } elseif ($success>0) {
206
+        } elseif ($success > 0) {
207 207
             $result = 'alert-confirmation';
208 208
         } elseif ($success == -2) {
209 209
             // we need to make sure we know that the person attempting to sign up
210 210
             // for the alert has that email address to stop people trying to work
211 211
             // out what alerts they are signed up to
212
-            if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) {
212
+            if ($this->data['email_verified'] || ($this->user->loggedin && $this->user->email() == $this->data['email'])) {
213 213
                 $result = 'alert-exists';
214 214
             } else {
215 215
                 // don't throw an error message as that implies that they have already signed
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
     private function formatSearchTerms() {
237
-        if ( $this->data['alertsearch'] ) {
237
+        if ($this->data['alertsearch']) {
238 238
             $this->data['alertsearch_pretty'] = $this->prettifyCriteria($this->data['alertsearch']);
239 239
             $this->data['search_text'] = $this->data['alertsearch'];
240 240
         } else {
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
 
245 245
     private function prettifyCriteria($alert_criteria) {
246 246
         $text = '';
247
-        if ( $alert_criteria ) {
247
+        if ($alert_criteria) {
248 248
             $criteria = explode(' ', $alert_criteria);
249 249
             $words = array();
250 250
             $spokenby = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($alert_criteria));
251 251
 
252 252
             foreach ($criteria as $c) {
253
-                if (!preg_match('#^speaker:(\d+)#',$c,$m)) {
253
+                if (!preg_match('#^speaker:(\d+)#', $c, $m)) {
254 254
                     $words[] = $c;
255 255
                 }
256 256
             }
257
-            if ( $spokenby && count($words) ) {
258
-                $text = implode(' or ', $spokenby) . ' mentions [' . implode(' ', $words) . ']';
259
-            } else if ( count( $words ) ) {
260
-                $text = '[' . implode(' ', $words) . ']' . ' is mentioned';
261
-            } else if ( $spokenby ) {
262
-                $text = implode(' or ', $spokenby) . " speaks";
257
+            if ($spokenby && count($words)) {
258
+                $text = implode(' or ', $spokenby).' mentions ['.implode(' ', $words).']';
259
+            } else if (count($words)) {
260
+                $text = '['.implode(' ', $words).']'.' is mentioned';
261
+            } else if ($spokenby) {
262
+                $text = implode(' or ', $spokenby)." speaks";
263 263
             }
264 264
 
265 265
             return $text;
@@ -293,38 +293,38 @@  discard block
 block discarded – undo
293 293
     }
294 294
 
295 295
     private function formatSearchMemberData() {
296
-        if ( isset($this->data['postcode']) ) {
296
+        if (isset($this->data['postcode'])) {
297 297
             try {
298 298
                 $postcode = $this->data['postcode'];
299 299
 
300
-                $MEMBER = new \MEMBER( array('postcode' => $postcode) );
300
+                $MEMBER = new \MEMBER(array('postcode' => $postcode));
301 301
                 // move the postcode to the front just to be tidy
302
-                $tidy_alertsearch = $postcode . " " . trim(str_replace("$postcode", "", $this->data['alertsearch']));
302
+                $tidy_alertsearch = $postcode." ".trim(str_replace("$postcode", "", $this->data['alertsearch']));
303 303
                 $alertsearch_display = str_replace("$postcode ", "", $tidy_alertsearch);
304 304
 
305
-                $this->data['member_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
305
+                $this->data['member_alertsearch'] = str_replace("$postcode", "speaker:".$MEMBER->person_id, $tidy_alertsearch);
306 306
                 $this->data['member_displaysearch'] = $alertsearch_display;
307 307
                 $this->data['member'] = $MEMBER;
308 308
 
309
-                if ( $this->data['scottish_text'] ) {
309
+                if ($this->data['scottish_text']) {
310 310
                     $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode);
311
-                    if ( isset($constituencies['SPC']) ) {
311
+                    if (isset($constituencies['SPC'])) {
312 312
                         $MEMBER = new \MEMBER(array('constituency' => $constituencies['SPC'], 'house' => 4));
313
-                        $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
313
+                        $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:".$MEMBER->person_id, $tidy_alertsearch);
314 314
                         $this->data['scottish_member'] = $MEMBER;
315 315
                     }
316 316
                 }
317
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
317
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
318 318
                 $this->data['member_error'] = 1;
319 319
             }
320 320
         }
321 321
 
322
-        if ( $this->data['pid'] ) {
323
-            $MEMBER = new \MEMBER( array('person_id' => $this->data['pid']) );
322
+        if ($this->data['pid']) {
323
+            $MEMBER = new \MEMBER(array('person_id' => $this->data['pid']));
324 324
             $this->data['pid_member'] = $MEMBER;
325 325
         }
326 326
 
327
-        if ( $this->data['keyword'] ) {
327
+        if ($this->data['keyword']) {
328 328
             $this->data['display_keyword'] = $this->prettifyCriteria($this->data['keyword']);
329 329
         }
330 330
     }
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
         for ($i = 0; $i < $num_alerts; $i++) {
355 355
             $row = $q->row($i);
356 356
             $criteria = $this->prettifyCriteria($row['criteria']);
357
-            $token = $row['alert_id'] . '-' . $row['registrationtoken'];
357
+            $token = $row['alert_id'].'-'.$row['registrationtoken'];
358 358
 
359 359
             $status = 'confirmed';
360
-            if ( !$row['confirmed'] ) {
360
+            if (!$row['confirmed']) {
361 361
                 $status = 'unconfirmed';
362
-            } elseif ( $row['deleted'] == 2 ) {
362
+            } elseif ($row['deleted'] == 2) {
363 363
                 $status = 'suspended';
364 364
             }
365 365
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -127,7 +127,9 @@
 block discarded – undo
127 127
         }
128 128
 
129 129
         $text = $this->data['alertsearch'];
130
-        if (!$text) $text = $this->data['keyword'];
130
+        if (!$text) {
131
+            $text = $this->data['keyword'];
132
+        }
131 133
 
132 134
         if ($this->data['submitted'] && !$this->data['pid'] && !$text) {
133 135
             $errors['alertsearch'] = 'Please enter what you want to be alerted about';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 class Standard extends \MySociety\TheyWorkForYou\AlertView {
13 13
     public $data;
14 14
 
15
-    public function __construct($THEUSER = NULL) {
15
+    public function __construct($THEUSER = null) {
16 16
         parent::__construct($THEUSER);
17 17
         $this->data = array();
18 18
     }
Please login to merge, or discard this patch.
classes/Renderer/User.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $edittext   = $menudata['text'];
50 50
         $edittitle  = $menudata['title'];
51 51
         $EDITURL    = new \URL('userviewself');
52
-        if ($this->page == 'userviewself' || $this->page == 'useredit' ) {
52
+        if ($this->page == 'userviewself' || $this->page == 'useredit') {
53 53
             $editclass = 'on';
54 54
         } else {
55 55
             $editclass = '';
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         // The 'Log out' link.
59 59
         $menudata   = $this->pagedata->page_metadata('userlogout', 'menu');
60 60
         $logouttext = $menudata['text'];
61
-        $logouttitle= $menudata['title'];
61
+        $logouttitle = $menudata['title'];
62 62
 
63 63
         $LOGOUTURL  = new \URL('userlogout');
64 64
         if ($this->page != 'userlogout') {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $logoutclass = 'on';
69 69
         }
70 70
 
71
-        $username = $this->user->firstname() . ' ' . $this->user->lastname();
71
+        $username = $this->user->firstname().' '.$this->user->lastname();
72 72
 
73 73
         $this->data['user_nav_links'][] = array(
74 74
             'href'    => $LOGOUTURL->generate(),
Please login to merge, or discard this patch.
classes/Renderer/Footer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
     public $data;
16 16
 
17
-    private $about_links = array ('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy');
17
+    private $about_links = array('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy');
18 18
     private $assemblies_links = array('hansard', 'sp_home', 'ni_home', 'wales_home');
19 19
     private $international_links = array('newzealand', 'australia', 'ireland', 'mzalendo');
20 20
     private $tech_links = array('code', 'api', 'data', 'pombola', 'devmailinglist', 'irc');
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     public function __construct() {
29 29
         $this->data = array();
30 30
 
31
-        $this->data['about'] = $this->get_menu_links( $this->about_links );
32
-        $this->data['assemblies'] = $this->get_menu_links( $this->assemblies_links );
33
-        $this->data['international'] = $this->get_menu_links( $this->international_links );
34
-        $this->data['tech'] = $this->get_menu_links( $this->tech_links );
31
+        $this->data['about'] = $this->get_menu_links($this->about_links);
32
+        $this->data['assemblies'] = $this->get_menu_links($this->assemblies_links);
33
+        $this->data['international'] = $this->get_menu_links($this->international_links);
34
+        $this->data['tech'] = $this->get_menu_links($this->tech_links);
35 35
     }
36 36
 
37 37
     /**
Please login to merge, or discard this patch.
classes/Model/Banner.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
     public function get_text() {
29 29
         $text = $this->mem->get('banner');
30 30
 
31
-        if ( $text === false ) {
31
+        if ($text === false) {
32 32
             $q = $this->db->query("SELECT value FROM editorial WHERE item = 'banner'");
33 33
 
34 34
             if ($q->rows) {
35 35
                 $text = $q->field(0, 'value');
36
-                if ( trim($text) == '' ) {
36
+                if (trim($text) == '') {
37 37
                     $text = NULL;
38 38
                 }
39 39
                 $this->mem->set('banner', $text, 86400);
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
             )
51 51
         );
52 52
 
53
-        if ( $q->success() ) {
54
-            if ( trim($text) == '' ) {
53
+        if ($q->success()) {
54
+            if (trim($text) == '') {
55 55
                 $text = NULL;
56 56
             }
57 57
             $this->mem->set('banner', $text, 86400);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             if ($q->rows) {
35 35
                 $text = $q->field(0, 'value');
36 36
                 if ( trim($text) == '' ) {
37
-                    $text = NULL;
37
+                    $text = null;
38 38
                 }
39 39
                 $this->mem->set('banner', $text, 86400);
40 40
             }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         if ( $q->success() ) {
54 54
             if ( trim($text) == '' ) {
55
-                $text = NULL;
55
+                $text = null;
56 56
             }
57 57
             $this->mem->set('banner', $text, 86400);
58 58
             return true;
Please login to merge, or discard this patch.
classes/Divisions.php 3 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -38,25 +38,25 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     public static function getMostRecentDivisionDate() {
41
-      $db = new \ParlDB;
42
-      $q = $db->query(
41
+        $db = new \ParlDB;
42
+        $q = $db->query(
43 43
         "SELECT policy_id, max(division_date) as recent from policydivisions GROUP BY policy_id"
44
-      );
44
+        );
45 45
 
46
-      $policy_maxes = array();
47
-      $row_count = $q->rows();
48
-      for ($n = 0; $n < $row_count; $n++) {
46
+        $policy_maxes = array();
47
+        $row_count = $q->rows();
48
+        for ($n = 0; $n < $row_count; $n++) {
49 49
         $policy_maxes[$q->field($n, 'policy_id')] = $q->field( $n, 'recent' );
50
-      }
51
-      $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52
-      return $policy_maxes;
50
+        }
51
+        $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52
+        return $policy_maxes;
53 53
     }
54 54
 
55 55
     public function getRecentDivisions($number = 20) {
56 56
         // Grab distinct divisions as sometimes we have the same division for more than one policy
57 57
         // and we don't want to display it twice
58 58
         $q = $this->db->query(
59
-          "SELECT distinct division_id, division_title, yes_text, no_text, division_date, division_number, gid, direction, majority_vote,
59
+            "SELECT distinct division_id, division_title, yes_text, no_text, division_date, division_number, gid, direction, majority_vote,
60 60
           yes_total, no_total, absent_total, both_total
61 61
           FROM policydivisions ORDER BY division_date DESC, division_number DESC LIMIT :count",
62 62
             array(
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $divisions = array();
95 95
         $row_count = $q->rows();
96 96
         for ($n = 0; $n < $row_count; $n++) {
97
-          $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
97
+            $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
98 98
         }
99 99
 
100 100
         return $divisions;
@@ -148,44 +148,44 @@  discard block
 block discarded – undo
148 148
 
149 149
         $row_count = $q->rows();
150 150
         for ($n = 0; $n < $row_count; $n++) {
151
-          $policy_id = $q->field($n, 'policy_id');
151
+            $policy_id = $q->field($n, 'policy_id');
152 152
 
153
-          if (!array_key_exists($policy_id, $policy_divisions)) {
153
+            if (!array_key_exists($policy_id, $policy_divisions)) {
154 154
             $summary = array(
155
-              'max' => $q->field($n, 'latest'),
156
-              'min' => $q->field($n, 'earliest'),
157
-              'total' => $q->field($n, 'total'),
158
-              'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0
155
+                'max' => $q->field($n, 'latest'),
156
+                'min' => $q->field($n, 'earliest'),
157
+                'total' => $q->field($n, 'total'),
158
+                'for' => 0, 'against' => 0, 'absent' => 0, 'both' => 0, 'tell' => 0
159 159
             );
160 160
 
161 161
             $policy_divisions[$policy_id] = $summary;
162
-          }
163
-
164
-          $summary = $policy_divisions[$policy_id];
165
-
166
-          $summary['total'] += $q->field($n, 'total');
167
-          if ($summary['max'] < $q->field($n, 'latest')) {
168
-              $summary['max'] = $q->field($n, 'latest');
169
-          }
170
-          if ($summary['min'] > $q->field($n, 'latest')) {
171
-              $summary['min'] = $q->field($n, 'latest');
172
-          }
173
-
174
-          $vote = $q->field($n, 'vote');
175
-          $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
-          if ( $vote == 'absent' ) {
177
-              $summary['absent'] += $q->field($n, 'total');
178
-          } else if ( $vote == 'both' ) {
179
-              $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
181
-              $summary['tell'] += $q->field($n, 'total');
182
-          } else if ( $policy_vote == $vote ) {
183
-              $summary['for'] += $q->field($n, 'total');
184
-          } else if ( $policy_vote != $vote ) {
185
-              $summary['against'] += $q->field($n, 'total');
186
-          }
187
-
188
-          $policy_divisions[$policy_id] = $summary;
162
+            }
163
+
164
+            $summary = $policy_divisions[$policy_id];
165
+
166
+            $summary['total'] += $q->field($n, 'total');
167
+            if ($summary['max'] < $q->field($n, 'latest')) {
168
+                $summary['max'] = $q->field($n, 'latest');
169
+            }
170
+            if ($summary['min'] > $q->field($n, 'latest')) {
171
+                $summary['min'] = $q->field($n, 'latest');
172
+            }
173
+
174
+            $vote = $q->field($n, 'vote');
175
+            $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
+            if ( $vote == 'absent' ) {
177
+                $summary['absent'] += $q->field($n, 'total');
178
+            } else if ( $vote == 'both' ) {
179
+                $summary['both'] += $q->field($n, 'total');
180
+            } else if ( strpos($vote, 'tell') !== FALSE ) {
181
+                $summary['tell'] += $q->field($n, 'total');
182
+            } else if ( $policy_vote == $vote ) {
183
+                $summary['for'] += $q->field($n, 'total');
184
+            } else if ( $policy_vote != $vote ) {
185
+                $summary['against'] += $q->field($n, 'total');
186
+            }
187
+
188
+            $policy_divisions[$policy_id] = $summary;
189 189
         }
190 190
 
191 191
         return $policy_divisions;
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
         );
220 220
 
221 221
         $votes = array(
222
-          'yes_votes' => array(),
223
-          'no_votes' => array(),
224
-          'absent_votes' => array(),
225
-          'both_votes' => array()
222
+            'yes_votes' => array(),
223
+            'no_votes' => array(),
224
+            'absent_votes' => array(),
225
+            'both_votes' => array()
226 226
         );
227 227
 
228 228
         foreach ($q->data as $vote) {
229 229
             $detail = array(
230
-              'person_id' => $vote['person_id'],
231
-              'name' => $vote['given_name'] . ' ' . $vote['family_name'],
232
-              'teller' => false
230
+                'person_id' => $vote['person_id'],
231
+                'name' => $vote['given_name'] . ' ' . $vote['family_name'],
232
+                'teller' => false
233 233
             );
234 234
 
235 235
             if (strpos($vote['vote'], 'tell') !== FALSE) {
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
             }
238 238
 
239 239
             if ($vote['vote'] == 'aye' or $vote['vote'] == 'tellaye') {
240
-              $votes['yes_votes'][] = $detail;
240
+                $votes['yes_votes'][] = $detail;
241 241
             } else if ($vote['vote'] == 'no' or $vote['vote'] == 'tellno') {
242
-              $votes['no_votes'][] = $detail;
242
+                $votes['no_votes'][] = $detail;
243 243
             } else if ($vote['vote'] == 'absent') {
244
-              $votes['absent_votes'][] = $detail;
244
+                $votes['absent_votes'][] = $detail;
245 245
             } else if ($vote['vote'] == 'both') {
246
-              $votes['both_votes'][] = $detail;
246
+                $votes['both_votes'][] = $detail;
247 247
             }
248 248
 
249 249
         }
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
         $divisions = array();
339 339
         $row_count = $q->rows();
340 340
         for ($n = 0; $n < $row_count; $n++) {
341
-          if ($context == 'Parliament') {
342
-              $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
343
-          } else {
344
-              $divisions[] = $this->getDivisionDetails($q->row($n));
345
-          }
341
+            if ($context == 'Parliament') {
342
+                $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
343
+            } else {
344
+                $divisions[] = $this->getDivisionDetails($q->row($n));
345
+            }
346 346
         }
347 347
 
348 348
         return $divisions;
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 
445 445
         $division['mp_vote'] = '';
446 446
         if (array_key_exists('vote', $row)) {
447
-          $mp_vote = ' was absent';
448
-          if ($row['vote'] == 'aye') {
449
-              $mp_vote = 'voted in favour';
450
-          } else if ($row['vote'] == 'no') {
451
-              $mp_vote = 'voted against';
452
-          }
453
-          $division['mp_vote'] = $mp_vote;
447
+            $mp_vote = ' was absent';
448
+            if ($row['vote'] == 'aye') {
449
+                $mp_vote = 'voted in favour';
450
+            } else if ($row['vote'] == 'no') {
451
+                $mp_vote = 'voted against';
452
+            }
453
+            $division['mp_vote'] = $mp_vote;
454 454
         }
455 455
         $division['division_title'] = $row['division_title'];
456 456
         $division['vote'] = $vote;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
       $policy_maxes = array();
47 47
       $row_count = $q->rows();
48 48
       for ($n = 0; $n < $row_count; $n++) {
49
-        $policy_maxes[$q->field($n, 'policy_id')] = $q->field( $n, 'recent' );
49
+        $policy_maxes[$q->field($n, 'policy_id')] = $q->field($n, 'recent');
50 50
       }
51 51
       $policy_maxes['latest'] = $policy_maxes ? max(array_values($policy_maxes)) : '';
52 52
       return $policy_maxes;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     public function getMemberDivisionsForPolicy($policyID = null) {
118 118
         $where_extra = '';
119 119
         $args = array(':person_id' => $this->member->person_id);
120
-        if ( $policyID ) {
120
+        if ($policyID) {
121 121
             $where_extra = 'AND policy_id = :policy_id';
122 122
             $args[':policy_id'] = $policyID;
123 123
         }
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 
174 174
           $vote = $q->field($n, 'vote');
175 175
           $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176
-          if ( $vote == 'absent' ) {
176
+          if ($vote == 'absent') {
177 177
               $summary['absent'] += $q->field($n, 'total');
178
-          } else if ( $vote == 'both' ) {
178
+          } else if ($vote == 'both') {
179 179
               $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
180
+          } else if (strpos($vote, 'tell') !== FALSE) {
181 181
               $summary['tell'] += $q->field($n, 'total');
182
-          } else if ( $policy_vote == $vote ) {
182
+          } else if ($policy_vote == $vote) {
183 183
               $summary['for'] += $q->field($n, 'total');
184
-          } else if ( $policy_vote != $vote ) {
184
+          } else if ($policy_vote != $vote) {
185 185
               $summary['against'] += $q->field($n, 'total');
186 186
           }
187 187
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         foreach ($q->data as $vote) {
229 229
             $detail = array(
230 230
               'person_id' => $vote['person_id'],
231
-              'name' => $vote['given_name'] . ' ' . $vote['family_name'],
231
+              'name' => $vote['given_name'].' '.$vote['family_name'],
232 232
               'teller' => false
233 233
             );
234 234
 
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
         $min = $votes['min'];
281 281
 
282 282
         $actions = array(
283
-            $votes['for'] . ' ' . make_plural('vote', $votes['for']) . ' for',
284
-            $votes['against'] . ' ' . make_plural('vote', $votes['against']) . ' against'
283
+            $votes['for'].' '.make_plural('vote', $votes['for']).' for',
284
+            $votes['against'].' '.make_plural('vote', $votes['against']).' against'
285 285
         );
286 286
 
287
-        if ( $votes['both'] ) {
288
-            $actions[] = $votes['both'] . ' ' . make_plural('abstention', $votes['both']);
287
+        if ($votes['both']) {
288
+            $actions[] = $votes['both'].' '.make_plural('abstention', $votes['both']);
289 289
         }
290
-        if ( $votes['absent'] ) {
291
-            $actions[] = $votes['absent'] . ' ' . make_plural('absence', $votes['absent']);
290
+        if ($votes['absent']) {
291
+            $actions[] = $votes['absent'].' '.make_plural('absence', $votes['absent']);
292 292
         }
293 293
         if ($max == $min) {
294
-            return join(', ', $actions) . ', in ' . $max;
294
+            return join(', ', $actions).', in '.$max;
295 295
         } else {
296
-            return join(', ', $actions) . ', between ' . $min . '&ndash;' . $max;
296
+            return join(', ', $actions).', between '.$min.'&ndash;'.$max;
297 297
         }
298 298
     }
299 299
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
     private function constructYesNoVoteDescription($direction, $title, $short_text) {
353 353
         $text = ' voted ';
354
-        if ( $short_text ) {
354
+        if ($short_text) {
355 355
             $text .= $short_text;
356 356
         } else {
357 357
             $text .= "$direction on <em>$title</em>";
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
          * votes so we need to generate some text using the title of the division
370 370
          */
371 371
 
372
-        switch ( strtolower($vote) ) {
372
+        switch (strtolower($vote)) {
373 373
             case 'yes':
374 374
             case 'aye':
375 375
                 $description = $this->constructYesNoVoteDescription('yes', $division_title, $yes_text);
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
                 $description = $this->constructYesNoVoteDescription('no', $division_title, $no_text);
379 379
                 break;
380 380
             case 'absent':
381
-                $description = ' was absent for a vote on <em>' . $division_title . '</em>';
381
+                $description = ' was absent for a vote on <em>'.$division_title.'</em>';
382 382
                 break;
383 383
             case 'both':
384
-                $description = ' abstained on a vote on <em>' . $division_title . '</em>';
384
+                $description = ' abstained on a vote on <em>'.$division_title.'</em>';
385 385
                 break;
386 386
             case 'tellyes':
387 387
             case 'tellno':
388 388
             case 'tellaye':
389
-                $description = ' acted as teller for a vote on <em>' . $division_title . '</em>';
389
+                $description = ' acted as teller for a vote on <em>'.$division_title.'</em>';
390 390
                 break;
391 391
             default:
392 392
                 $description = $division_title;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         $division = array();
400 400
 
401 401
         $direction = $row['direction'];
402
-        if ( strpos( $direction, 'strong') !== FALSE ) {
402
+        if (strpos($direction, 'strong') !== FALSE) {
403 403
             $division['strong'] = TRUE;
404 404
         } else {
405 405
             $division['strong'] = FALSE;
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
         $division['division_title'] = $row['division_title'];
456 456
         $division['vote'] = $vote;
457 457
 
458
-        $division['summary'] = $row['yes_total'] . ' for, ' . $row['no_total'] . ' against, ' . $row['absent_total'] . ' absent';
458
+        $division['summary'] = $row['yes_total'].' for, '.$row['no_total'].' against, '.$row['absent_total'].' absent';
459 459
         $division['for'] = $row['yes_total'];
460 460
         $division['against'] = $row['no_total'];
461 461
         $division['both'] = $row['both_total'];
@@ -471,24 +471,24 @@  discard block
 block discarded – undo
471 471
         for ($n = 0; $n < $row_count; $n++) {
472 472
             $policy_id = $q->field($n, 'policy_id');
473 473
 
474
-            if ( !array_key_exists($policy_id, $policies) ) {
474
+            if (!array_key_exists($policy_id, $policies)) {
475 475
                 $policies[$policy_id] = array(
476 476
                     'policy_id' => $policy_id,
477 477
                     'weak_count' => 0,
478 478
                     'divisions' => array()
479 479
                 );
480
-                if ( $this->policies ) {
480
+                if ($this->policies) {
481 481
                     $policies[$policy_id]['desc'] = $this->policies->getPolicies()[$policy_id];
482 482
                     $policies[$policy_id]['header'] = $this->policies->getPolicyDetails($policy_id);
483 483
                 }
484
-                if ( $this->positions ) {
484
+                if ($this->positions) {
485 485
                     $policies[$policy_id]['position'] = $this->positions->positionsById[$policy_id];
486 486
                 }
487 487
             }
488 488
 
489 489
             $division = $this->getDivisionDetails($q->row($n));
490 490
 
491
-            if ( !$division['strong'] ) {
491
+            if (!$division['strong']) {
492 492
                 $policies[$policy_id]['weak_count']++;
493 493
             }
494 494
 
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 
504 504
         $gid = get_canonical_gid($gid);
505 505
 
506
-        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array( ':gid' => $gid ));
506
+        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array(':gid' => $gid));
507 507
         $parent_gid = $q->field(0, 'gid');
508
-        if ( !$parent_gid ) {
508
+        if (!$parent_gid) {
509 509
             return '';
510 510
         }
511 511
         $parent_gid = fix_gid_from_db($parent_gid);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param Member   $member   The member to get positions for.
30 30
      */
31 31
 
32
-    public function __construct(Member $member = NULL, PolicyPositions $positions = NULL, Policies $policies = NULL)
32
+    public function __construct(Member $member = null, PolicyPositions $positions = null, Policies $policies = null)
33 33
     {
34 34
         $this->member = $member;
35 35
         $this->positions = $positions;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
               $summary['absent'] += $q->field($n, 'total');
178 178
           } else if ( $vote == 'both' ) {
179 179
               $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
180
+          } else if ( strpos($vote, 'tell') !== false ) {
181 181
               $summary['tell'] += $q->field($n, 'total');
182 182
           } else if ( $policy_vote == $vote ) {
183 183
               $summary['for'] += $q->field($n, 'total');
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
               'teller' => false
233 233
             );
234 234
 
235
-            if (strpos($vote['vote'], 'tell') !== FALSE) {
235
+            if (strpos($vote['vote'], 'tell') !== false) {
236 236
                 $detail['teller'] = true;
237 237
             }
238 238
 
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
         $division = array();
400 400
 
401 401
         $direction = $row['direction'];
402
-        if ( strpos( $direction, 'strong') !== FALSE ) {
403
-            $division['strong'] = TRUE;
402
+        if ( strpos( $direction, 'strong') !== false ) {
403
+            $division['strong'] = true;
404 404
         } else {
405
-            $division['strong'] = FALSE;
405
+            $division['strong'] = false;
406 406
         }
407 407
 
408 408
         $division['division_id'] = $row['division_id'];
Please login to merge, or discard this patch.
classes/Party.php 3 patches
Spacing   +25 added lines, -25 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;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 ':date' => date('Y-m-d'),
43 43
             )
44 44
         );
45
-        if ( $member_count->rows ) {
45
+        if ($member_count->rows) {
46 46
             $num_members = $member_count->field(0, 'num_members');
47 47
             return $num_members;
48 48
         } else {
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
             )
71 71
         );
72 72
 
73
-        if ( $position->rows ) {
73
+        if ($position->rows) {
74 74
             $score = $position->field(0, '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,
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             );
123 123
         }
124 124
 
125
-        for ( $i = 0; $i < $num_divs; $i++ ) {
125
+        for ($i = 0; $i < $num_divs; $i++) {
126 126
             $division_id = $divisions->field($i, 'division_id');
127 127
             $weights = $this->get_vote_scores($divisions->field($i, 'policy_vote'));
128 128
 
@@ -142,42 +142,42 @@  discard block
 block discarded – undo
142 142
             );
143 143
 
144 144
             $num_votes = 0;
145
-            for ( $j = 0; $j < $votes->rows(); $j++ ) {
145
+            for ($j = 0; $j < $votes->rows(); $j++) {
146 146
                 $vote_dir = $votes->field($j, '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 += $votes->field($j, 'num_votes');
152 152
                 $score += ($votes->field($j, '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 {
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         $parties = array();
257 257
         $party_count = $party_list->rows;
258 258
 
259
-        for ( $i = 0; $i < $party_count; $i++ ) {
259
+        for ($i = 0; $i < $party_count; $i++) {
260 260
             $party = $party_list->field($i, 'party');
261 261
             if (
262 262
                 !$party
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
             for ( $j = 0; $j < $votes->rows(); $j++ ) {
146 146
                 $vote_dir = $votes->field($j, '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 += $votes->field($j, 'num_votes');
152 158
                 $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]);
Please login to merge, or discard this patch.
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.