Failed Conditions
Pull Request — master (#1325)
by Nick
51:22 queued 41:09
created
classes/Utility/Video.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
     }
20 20
 
21 21
     public static function fromTimestamp($videodb, $date, $time) {
22
-        if (!$videodb) return null;
22
+        if (!$videodb) {
23
+            return null;
24
+        }
23 25
         date_default_timezone_set('Europe/London');
24 26
         $epoch = strtotime("$date $time");
25 27
         $timestamp = gmdate('c', $epoch);
@@ -38,9 +40,13 @@  discard block
 block discarded – undo
38 40
 
39 41
     public static function object($video_id, $start, $gid, $stamping = '', $pid = 0) {
40 42
         $flashvars = "gid=$gid&file=$video_id&start=$start";
41
-        if ($stamping) $flashvars .= '&stamping=1';
42
-        if ($pid) $flashvars .= '&pid=' . $pid;
43
-/*
43
+        if ($stamping) {
44
+            $flashvars .= '&stamping=1';
45
+        }
46
+        if ($pid) {
47
+            $flashvars .= '&pid=' . $pid;
48
+        }
49
+        /*
44 50
 <object width='360' height='300'
45 51
     classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
46 52
     codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
     public static function dbConnect() {
15
-        $connstr = 'host='.OPTION_BBC_DB_HOST.' port='.OPTION_BBC_DB_PORT.' dbname='.OPTION_BBC_DB_NAME.' user='.OPTION_BBC_DB_USER.' password='.OPTION_BBC_DB_PASS;
15
+        $connstr = 'host=' . OPTION_BBC_DB_HOST . ' port=' . OPTION_BBC_DB_PORT . ' dbname=' . OPTION_BBC_DB_NAME . ' user=' . OPTION_BBC_DB_USER . ' password=' . OPTION_BBC_DB_PASS;
16 16
         $videodb = pg_connect($connstr);
17 17
 
18 18
         return $videodb;
Please login to merge, or discard this patch.
classes/Utility/Hansard.php 3 patches
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 ));
39
+        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
40 40
         $url_gid = fix_gid_from_db($gid);
41 41
         $url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
42 42
         $url->insert(array('id' => $url_gid));
Please login to merge, or discard this 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
 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.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,9 +18,11 @@
 block discarded – undo
18 18
         if ( $query['id'] ) {
19 19
             if (strpos($parts['path'], 'lords') !== false) {
20 20
                 $gid = 'uk.org.publicwhip/lords/';
21
-            } elseif (strpos($parts['path'], 'whall') !== false) {
21
+            }
22
+            elseif (strpos($parts['path'], 'whall') !== false) {
22 23
                 $gid = 'uk.org.publicwhip/westminhall/';
23
-            } else {
24
+            }
25
+            else {
24 26
                 $gid = 'uk.org.publicwhip/debate/';
25 27
             }
26 28
             $gid .= $query['id'];
Please login to merge, or discard this patch.
classes/Utility/Wikipedia.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -136,63 +136,63 @@
 block discarded – undo
136 136
 
137 137
     public static function antiTagInTag($content = '', $format = 'htmlhead')
138 138
     {
139
-      $contentwalker = 0;
140
-      $length = strlen( $content );
141
-      $tagend = -1;
142
-      for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
139
+        $contentwalker = 0;
140
+        $length = strlen( $content );
141
+        $tagend = -1;
142
+        for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
143 143
         {
144
-          // got the start of a tag.  Now find the proper end!
145
-          $walker = $tagstart + 1;
146
-          $open = 1;
147
-          while( $open != 0 && $walker < strlen( $content ) )
144
+            // got the start of a tag.  Now find the proper end!
145
+            $walker = $tagstart + 1;
146
+            $open = 1;
147
+            while( $open != 0 && $walker < strlen( $content ) )
148 148
         {
149
-          $nextopen = strpos( $content, '<', $walker );
150
-          $nextclose = strpos( $content, '>', $walker );
151
-          if( $nextclose === false )
149
+            $nextopen = strpos( $content, '<', $walker );
150
+            $nextclose = strpos( $content, '>', $walker );
151
+            if( $nextclose === false )
152 152
             {    // ERROR! Open waka without close waka!
153
-              // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154
-              return $content;
153
+                // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154
+                return $content;
155 155
             }
156
-          if( $nextopen === false || $nextopen > $nextclose )
156
+            if( $nextopen === false || $nextopen > $nextclose )
157 157
             { // No more opens, but there was a close; or, a close happens before the next open.
158
-              // walker goes to the close+1, and open decrements
159
-              $open --;
160
-              $walker = $nextclose + 1;
158
+                // walker goes to the close+1, and open decrements
159
+                $open --;
160
+                $walker = $nextclose + 1;
161 161
             }
162
-          elseif( $nextopen < $nextclose )
162
+            elseif( $nextopen < $nextclose )
163 163
             { // an open before the next close
164
-              $open ++;
165
-              $walker = $nextopen + 1;
164
+                $open ++;
165
+                $walker = $nextopen + 1;
166 166
             }
167 167
         }
168
-          $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
168
+            $tagend = $walker;
169
+            if( $tagend > strlen( $content ) )
170 170
         $tagend = strlen( $content );
171
-          else
171
+            else
172 172
         {
173
-          $tagend --;
174
-          $tagstart ++;
173
+            $tagend --;
174
+            $tagstart ++;
175 175
         }
176
-          $tag = substr( $content, $tagstart, $tagend - $tagstart );
177
-          $tags[] = '<' . $tag . '>';
176
+            $tag = substr( $content, $tagstart, $tagend - $tagstart );
177
+            $tags[] = '<' . $tag . '>';
178 178
 
179
-          if (function_exists('format_to_output')) {
179
+            if (function_exists('format_to_output')) {
180 180
             $newtag = format_to_output($tag, $format);
181
-          } else {
181
+            } else {
182 182
             $newtag = strip_tags($tag);
183
-          }
183
+            }
184 184
 
185
-          $newtags[] = '<' . $newtag . '>';
185
+            $newtags[] = '<' . $newtag . '>';
186 186
 
187
-          if (function_exists('format_to_output')) {
187
+            if (function_exists('format_to_output')) {
188 188
             $newtag = format_to_output($tag, $format);
189
-          } else {
189
+            } else {
190 190
             $newtag = strip_tags($tag);
191
-          }
191
+            }
192
+        }
193
+        if (isset($tags)&&isset($newtags)) {
194
+        $content = str_replace($tags, $newtags, $content);
192 195
         }
193
-      if (isset($tags)&&isset($newtags)) {
194
-      $content = str_replace($tags, $newtags, $content);
195
-      }
196 196
 
197 197
     return $content;
198 198
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $source = explode('|||', $source);
84 84
         $q = $db->query("SELECT titles.title FROM titles LEFT JOIN titles_ignored ON titles.title=titles_ignored.title WHERE titles.title IN (" . join(',', array_keys($params)) . ") AND titles_ignored.title IS NULL", $params);
85 85
         $phrases = array();
86
-        for ($i=0; $i<$q->rows(); $i++) {
86
+        for ($i = 0; $i < $q->rows(); $i++) {
87 87
             $phrases[] = $q->field($i, 'title');
88 88
         }
89 89
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
             twfy_debug("WIKIPEDIA", "Matched '$phrase'");
107 107
             # 1 means only replace one match for phrase per paragraph
108
-            $source = preg_replace ('{
108
+            $source = preg_replace('{
109 109
             \b(' . $phrase_re . ')\b # Match the phrase itself
110 110
             (?!                      # Match as long as the following does *not* apply:
111 111
                 (?:                  #   Match, possessively, as many strings of:
@@ -137,43 +137,43 @@  discard block
 block discarded – undo
137 137
     public static function antiTagInTag($content = '', $format = 'htmlhead')
138 138
     {
139 139
       $contentwalker = 0;
140
-      $length = strlen( $content );
140
+      $length = strlen($content);
141 141
       $tagend = -1;
142
-      for( $tagstart = strpos( $content, '<', $tagend + 1 ) ; $tagstart !== false && $tagstart < strlen( $content ); $tagstart = strpos( $content, '<', $tagend ) )
142
+      for ($tagstart = strpos($content, '<', $tagend + 1); $tagstart !== false && $tagstart < strlen($content); $tagstart = strpos($content, '<', $tagend))
143 143
         {
144 144
           // got the start of a tag.  Now find the proper end!
145 145
           $walker = $tagstart + 1;
146 146
           $open = 1;
147
-          while( $open != 0 && $walker < strlen( $content ) )
147
+          while ($open != 0 && $walker < strlen($content))
148 148
         {
149
-          $nextopen = strpos( $content, '<', $walker );
150
-          $nextclose = strpos( $content, '>', $walker );
151
-          if( $nextclose === false )
149
+          $nextopen = strpos($content, '<', $walker);
150
+          $nextclose = strpos($content, '>', $walker);
151
+          if ($nextclose === false)
152 152
             {    // ERROR! Open waka without close waka!
153 153
               // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154 154
               return $content;
155 155
             }
156
-          if( $nextopen === false || $nextopen > $nextclose )
156
+          if ($nextopen === false || $nextopen > $nextclose)
157 157
             { // No more opens, but there was a close; or, a close happens before the next open.
158 158
               // walker goes to the close+1, and open decrements
159
-              $open --;
159
+              $open--;
160 160
               $walker = $nextclose + 1;
161 161
             }
162
-          elseif( $nextopen < $nextclose )
162
+          elseif ($nextopen < $nextclose)
163 163
             { // an open before the next close
164
-              $open ++;
164
+              $open++;
165 165
               $walker = $nextopen + 1;
166 166
             }
167 167
         }
168 168
           $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
170
-        $tagend = strlen( $content );
169
+          if ($tagend > strlen($content))
170
+        $tagend = strlen($content);
171 171
           else
172 172
         {
173
-          $tagend --;
174
-          $tagstart ++;
173
+          $tagend--;
174
+          $tagstart++;
175 175
         }
176
-          $tag = substr( $content, $tagstart, $tagend - $tagstart );
176
+          $tag = substr($content, $tagstart, $tagend - $tagstart);
177 177
           $tags[] = '<' . $tag . '>';
178 178
 
179 179
           if (function_exists('format_to_output')) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
             $newtag = strip_tags($tag);
191 191
           }
192 192
         }
193
-      if (isset($tags)&&isset($newtags)) {
193
+      if (isset($tags) && isset($newtags)) {
194 194
       $content = str_replace($tags, $newtags, $content);
195 195
       }
196 196
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -16 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 
100 100
             # See if already matched a string this one is contained within
101 101
             foreach ($matched as $got) {
102
-                if (strstr($got, $phrase))
103
-                    continue 2;
102
+                if (strstr($got, $phrase)) {
103
+                                    continue 2;
104
+                }
104 105
             }
105 106
 
106 107
             twfy_debug("WIKIPEDIA", "Matched '$phrase'");
@@ -119,8 +120,9 @@  discard block
 block discarded – undo
119 120
             array_push($matched, $phrase);
120 121
         }
121 122
 
122
-        if (!$was_array)
123
-            $source = join('|||', $source);
123
+        if (!$was_array) {
124
+                    $source = join('|||', $source);
125
+        }
124 126
 
125 127
         return $source;
126 128
 
@@ -148,28 +150,28 @@  discard block
 block discarded – undo
148 150
         {
149 151
           $nextopen = strpos( $content, '<', $walker );
150 152
           $nextclose = strpos( $content, '>', $walker );
151
-          if( $nextclose === false )
152
-            {    // ERROR! Open waka without close waka!
153
+          if( $nextclose === false ) {
154
+// ERROR! Open waka without close waka!
153 155
               // echo '<code>Error in antiTagInTag - malformed tag!</code> ';
154 156
               return $content;
155 157
             }
156
-          if( $nextopen === false || $nextopen > $nextclose )
157
-            { // No more opens, but there was a close; or, a close happens before the next open.
158
+          if( $nextopen === false || $nextopen > $nextclose ) {
159
+// No more opens, but there was a close; or, a close happens before the next open.
158 160
               // walker goes to the close+1, and open decrements
159 161
               $open --;
160 162
               $walker = $nextclose + 1;
161 163
             }
162
-          elseif( $nextopen < $nextclose )
163
-            { // an open before the next close
164
+            elseif( $nextopen < $nextclose ) {
165
+// an open before the next close
164 166
               $open ++;
165 167
               $walker = $nextopen + 1;
166 168
             }
167 169
         }
168 170
           $tagend = $walker;
169
-          if( $tagend > strlen( $content ) )
170
-        $tagend = strlen( $content );
171
-          else
172
-        {
171
+          if( $tagend > strlen( $content ) ) {
172
+                  $tagend = strlen( $content );
173
+          }
174
+          else {
173 175
           $tagend --;
174 176
           $tagstart ++;
175 177
         }
@@ -178,7 +180,8 @@  discard block
 block discarded – undo
178 180
 
179 181
           if (function_exists('format_to_output')) {
180 182
             $newtag = format_to_output($tag, $format);
181
-          } else {
183
+          }
184
+          else {
182 185
             $newtag = strip_tags($tag);
183 186
           }
184 187
 
@@ -186,7 +189,8 @@  discard block
 block discarded – undo
186 189
 
187 190
           if (function_exists('format_to_output')) {
188 191
             $newtag = format_to_output($tag, $format);
189
-          } else {
192
+          }
193
+          else {
190 194
             $newtag = strip_tags($tag);
191 195
           }
192 196
         }
Please login to merge, or discard this patch.
classes/Utility/Constituencies.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,13 +31,15 @@
 block discarded – undo
31 31
         $q1 = $db->query($query, array(
32 32
             ':name' => $name
33 33
             ));
34
-        if ($q1->rows <= 0)
35
-            return false;
34
+        if ($q1->rows <= 0) {
35
+                    return false;
36
+        }
36 37
 
37 38
         $query = "select name from constituency where main_name and cons_id = '".$q1->field(0,'cons_id')."'";
38 39
         $q2 = $db->query($query);
39
-        if ($q2->rows <= 0)
40
-            return false;
40
+        if ($q2->rows <= 0) {
41
+                    return false;
42
+        }
41 43
 
42 44
         return $q2->field(0, "name");
43 45
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         if ($q1->rows <= 0)
35 35
             return false;
36 36
 
37
-        $query = "select name from constituency where main_name and cons_id = '".$q1->field(0,'cons_id')."'";
37
+        $query = "select name from constituency where main_name and cons_id = '" . $q1->field(0, 'cons_id') . "'";
38 38
         $q2 = $db->query($query);
39 39
         if ($q2->rows <= 0)
40 40
             return false;
Please login to merge, or discard this patch.
classes/Topics.php 4 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,59 +25,59 @@
 block discarded – undo
25 25
     }
26 26
 
27 27
     public function getTopics() {
28
-      $q = $this->db->query("SELECT id, slug, title, description, search_string, front_page, image FROM topics");
28
+        $q = $this->db->query("SELECT id, slug, title, description, search_string, front_page, image FROM topics");
29 29
 
30
-      $topics = array();
31
-      $count = $q->rows();
30
+        $topics = array();
31
+        $count = $q->rows();
32 32
 
33
-      for ($i = 0; $i < $count; $i++ ) {
34
-          $topic = $q->row($i);
35
-          $topics[$topic['slug']] = new Topic($topic);
36
-      }
37
-      return $topics;
33
+        for ($i = 0; $i < $count; $i++ ) {
34
+            $topic = $q->row($i);
35
+            $topics[$topic['slug']] = new Topic($topic);
36
+        }
37
+        return $topics;
38 38
     }
39 39
 
40 40
     public function getTopic($topic_name) {
41
-      $q = $this->db->query(
42
-          "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug",
43
-          array(':slug' => $topic_name)
44
-      );
45
-      if ($q->rows) {
46
-          return new Topic($q->row(0));
47
-      }
48
-
49
-      return NULL;
41
+        $q = $this->db->query(
42
+            "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE slug = :slug",
43
+            array(':slug' => $topic_name)
44
+        );
45
+        if ($q->rows) {
46
+            return new Topic($q->row(0));
47
+        }
48
+
49
+        return NULL;
50 50
     }
51 51
 
52 52
     public function getFrontPageTopics() {
53
-      $q = $this->db->query(
54
-          "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE front_page = TRUE"
55
-      );
56
-
57
-      $topics = array();
58
-      $count = $q->rows();
59
-
60
-      for ($i = 0; $i < $count; $i++ ) {
61
-          $topic = $q->row($i);
62
-          $topics[$topic['slug']] = new Topic($topic);
63
-      }
64
-      return $topics;
53
+        $q = $this->db->query(
54
+            "SELECT id, slug, title, description, search_string, front_page, image FROM topics WHERE front_page = TRUE"
55
+        );
56
+
57
+        $topics = array();
58
+        $count = $q->rows();
59
+
60
+        for ($i = 0; $i < $count; $i++ ) {
61
+            $topic = $q->row($i);
62
+            $topics[$topic['slug']] = new Topic($topic);
63
+        }
64
+        return $topics;
65 65
     }
66 66
 
67 67
     public function updateFrontPageTopics($topics) {
68 68
         // PDO doesn't cope with arrays so we have to do this by hand :|
69 69
         $quoted = array();
70 70
         if ($topics) {
71
-          foreach ($topics as $topic) {
72
-              $quoted[] = $this->db->quote($topic);
73
-          }
74
-          $topics_str = implode(',', $quoted);
71
+            foreach ($topics as $topic) {
72
+                $quoted[] = $this->db->quote($topic);
73
+            }
74
+            $topics_str = implode(',', $quoted);
75 75
 
76
-          $q = $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)");
76
+            $q = $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)");
77 77
 
78
-          $q = $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)");
78
+            $q = $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)");
79 79
         } else {
80
-          $q = $this->db->query("UPDATE topics SET front_page = FALSE");
80
+            $q = $this->db->query("UPDATE topics SET front_page = FALSE");
81 81
         }
82 82
 
83 83
         return true;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
       $topics = array();
31 31
       $count = $q->rows();
32 32
 
33
-      for ($i = 0; $i < $count; $i++ ) {
33
+      for ($i = 0; $i < $count; $i++) {
34 34
           $topic = $q->row($i);
35 35
           $topics[$topic['slug']] = new Topic($topic);
36 36
       }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
       $topics = array();
58 58
       $count = $q->rows();
59 59
 
60
-      for ($i = 0; $i < $count; $i++ ) {
60
+      for ($i = 0; $i < $count; $i++) {
61 61
           $topic = $q->row($i);
62 62
           $topics[$topic['slug']] = new Topic($topic);
63 63
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
           return new Topic($q->row(0));
47 47
       }
48 48
 
49
-      return NULL;
49
+      return null;
50 50
     }
51 51
 
52 52
     public function getFrontPageTopics() {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,8 @@
 block discarded – undo
76 76
           $q = $this->db->query("UPDATE topics SET front_page = TRUE WHERE slug IN ($topics_str)");
77 77
 
78 78
           $q = $this->db->query("UPDATE topics SET front_page = FALSE WHERE slug NOT IN ($topics_str)");
79
-        } else {
79
+        }
80
+        else {
80 81
           $q = $this->db->query("UPDATE topics SET front_page = FALSE");
81 82
         }
82 83
 
Please login to merge, or discard this patch.
classes/Policies.php 4 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     }
310 310
 
311 311
     public function getSetDescriptions() {
312
-      return $this->set_descs;
312
+        return $this->set_descs;
313 313
     }
314 314
 
315 315
     /**
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
     }
398 398
 
399 399
     public function limitToArray($policies) {
400
-          $out = array();
401
-          // Reassemble the new policies list based on the set.
402
-          foreach ($policies as $policy) {
403
-              if (isset($this->policies[$policy])) {
404
-                  $out[$policy] = $this->policies[$policy];
405
-              }
406
-          }
407
-
408
-          $new_policies = new self();
409
-          $new_policies->policies = $out;
410
-
411
-          return $new_policies;
400
+            $out = array();
401
+            // Reassemble the new policies list based on the set.
402
+            foreach ($policies as $policy) {
403
+                if (isset($this->policies[$policy])) {
404
+                    $out[$policy] = $this->policies[$policy];
405
+                }
406
+            }
407
+
408
+            $new_policies = new self();
409
+            $new_policies->policies = $out;
410
+
411
+            return $new_policies;
412 412
     }
413 413
 
414 414
     public function getPolicyDetails($policyID) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
 
294 294
     private $policy_id;
295 295
 
296
-    public function __construct($policy_id = NULL) {
296
+    public function __construct($policy_id = null) {
297 297
         $this->db = new \ParlDB;
298 298
 
299 299
         if ( $policy_id ) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     public function __construct($policy_id = NULL) {
297 297
         $this->db = new \ParlDB;
298 298
 
299
-        if ( $policy_id ) {
299
+        if ($policy_id) {
300 300
             $this->policy_id = $policy_id;
301 301
             $this->policies = array(
302 302
                 $policy_id => $this->policies[$policy_id]
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
                     // want to complain here if we're looking for that policy and
381 381
                     // it does not exist. Otherwise, if the single policy isn't in
382 382
                     // the set we want to return an empty set
383
-                    if ( !isset($this->policy_id) || $set_policy == $this->policy_id ) {
384
-                        throw new \Exception ('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.');
383
+                    if (!isset($this->policy_id) || $set_policy == $this->policy_id) {
384
+                        throw new \Exception('Policy ' . $set_policy . ' in set "' . $set . '" does not exist.');
385 385
                     }
386 386
                 }
387 387
             }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             return $new_policies;
393 393
 
394 394
         } else {
395
-            throw new \Exception ('Policy set "' . $set . '" does not exist.');
395
+            throw new \Exception('Policy set "' . $set . '" does not exist.');
396 396
         }
397 397
     }
398 398
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
         $image = $q->field(0, 'image');
435 435
 
436
-        if ( $image && file_exists(BASEDIR . '/' . $image)) {
436
+        if ($image && file_exists(BASEDIR . '/' . $image)) {
437 437
             $props['image'] = $image;
438 438
             $props['image_license'] = $q->field(0, 'image_license');
439 439
             $props['image_attribution'] = $q->field(0, 'image_attrib');
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -366,16 +366,15 @@  discard block
 block discarded – undo
366 366
     public function limitToSet($set) {
367 367
 
368 368
         // Sanity check the set exists
369
-        if (isset($this->sets[$set]))
370
-        {
369
+        if (isset($this->sets[$set])) {
371 370
             $out = array();
372 371
             // Reassemble the new policies list based on the set.
373 372
             foreach ($this->sets[$set] as $set_policy)
374 373
             {
375
-                if (isset($this->policies[$set_policy]))
376
-                {
374
+                if (isset($this->policies[$set_policy])) {
377 375
                     $out[$set_policy] = $this->policies[$set_policy];
378
-                } else {
376
+                }
377
+                else {
379 378
                     // if we've limited the policies to a single one then we only
380 379
                     // want to complain here if we're looking for that policy and
381 380
                     // it does not exist. Otherwise, if the single policy isn't in
@@ -391,7 +390,8 @@  discard block
 block discarded – undo
391 390
 
392 391
             return $new_policies;
393 392
 
394
-        } else {
393
+        }
394
+        else {
395 395
             throw new \Exception ('Policy set "' . $set . '" does not exist.');
396 396
         }
397 397
     }
Please login to merge, or discard this patch.
classes/Search.php 3 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.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,12 +34,14 @@  discard block
 block discarded – undo
34 34
             $data['searchstring'] = $this->searchstring;
35 35
             $data = $this->get_form_params($data);
36 36
             return $data;
37
-        } else {
37
+        }
38
+        else {
38 39
             if (get_http_var('o')=='p') {
39 40
                 $search = new Search\ByUsage();
40 41
                 $data = $search->search($this->searchstring);
41 42
                 $data['template'] = 'search/by-person';
42
-            } else {
43
+            }
44
+            else {
43 45
                 $search = new Search\Normal();
44 46
                 $data = $search->search($this->searchstring);
45 47
                 $data['template'] = 'search/results';
@@ -203,7 +205,8 @@  discard block
 block discarded – undo
203 205
             if ( get_http_var('wtt') ) {
204 206
                 $url->insert(array('wtt' => get_http_var('wtt')));
205 207
             }
206
-        } else {
208
+        }
209
+        else {
207 210
             $url->remove(array('o', 'house'));
208 211
         }
209 212
 
@@ -217,10 +220,12 @@  discard block
 block discarded – undo
217 220
         if ( isset($data['search_type']) && $data['search_type'] == 'person' ) {
218 221
             if (isset($data['wtt']) && $data['wtt'] > 0) {
219 222
                 $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
220
-            } else {
223
+            }
224
+            else {
221 225
                 $pagetitle = 'Who says ' . $data['pagetitle'] . ' the most?';
222 226
             }
223
-        } else {
227
+        }
228
+        else {
224 229
             $pagetitle = 'Search for ' . $data['searchdescription'];
225 230
             if (isset($data['info']['page']) && $data['info']['page'] > 1) {
226 231
                 $pagetitle .= ", page " . $data['info']['page'];
Please login to merge, or discard this patch.
classes/Utility/Gaze.php 2 patches
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.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@
 block discarded – undo
24 24
 
25 25
         if (defined('OPTION_GAZE_URL') && OPTION_GAZE_URL) {
26 26
             return gaze_get_country_from_ip($ip);
27
-        } else {
27
+        }
28
+        else {
28 29
             return NULL;
29 30
         }
30 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->field(0, '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   +71 added lines, -29 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,13 +77,17 @@  discard block
 block discarded – undo
75 77
             $name = $q->field(0, '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
-            } elseif (self::postcodeIsNi($postcode)) {
80
+                if (count($name)==3) {
81
+                                    return array('WMC' => $name[0], 'SPC' => $name[1], 'SPE' => $name[2]);
82
+                }
83
+            }
84
+            elseif (self::postcodeIsNi($postcode)) {
81 85
                 $name = explode('|', $name);
82
-                if (count($name)==2)
83
-                    return array('WMC' => $name[0], 'NIE' => $name[1]);
84
-            } else {
86
+                if (count($name)==2) {
87
+                                    return array('WMC' => $name[0], 'NIE' => $name[1]);
88
+                }
89
+            }
90
+            else {
85 91
                 return array('WMC' => $name);
86 92
             }
87 93
         }
@@ -121,8 +127,9 @@  discard block
 block discarded – undo
121 127
         }
122 128
         $areas = array();
123 129
         foreach ($r['areas'] as $row) {
124
-            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE')))
125
-                $areas[$row['type']] = $row['name'];
130
+            if (in_array($row['type'], array('WMC', 'SPC', 'SPE', 'NIE'))) {
131
+                            $areas[$row['type']] = $row['name'];
132
+            }
126 133
         }
127 134
 
128 135
         if (!isset($areas['WMC'])) {
@@ -135,9 +142,11 @@  discard block
 block discarded – undo
135 142
             $areas['WMC'] = $normalised;
136 143
             if (self::postcodeIsScottish($postcode)) {
137 144
                 $serialized = "$areas[WMC]|$areas[SPC]|$areas[SPE]";
138
-            } elseif (self::postcodeIsNi($postcode)) {
145
+            }
146
+            elseif (self::postcodeIsNi($postcode)) {
139 147
                 $serialized = "$areas[WMC]|$areas[NIE]";
140
-            } else {
148
+            }
149
+            else {
141 150
                 $serialized = $normalised;
142 151
             }
143 152
             $db = new \ParlDB;
@@ -146,7 +155,8 @@  discard block
 block discarded – undo
146 155
                     ':postcode' => $postcode,
147 156
                     ':serialized' => $serialized
148 157
                 ));
149
-        } else {
158
+        }
159
+        else {
150 160
             return '';
151 161
         }
152 162
 
@@ -172,36 +182,67 @@  discard block
 block discarded – undo
172 182
      */
173 183
 
174 184
     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;
185
+        if (!preg_match('#^([A-Z]{1,2})(\d+) (\d)([A-Z]{2})#', self::canonicalisePostcode($pc), $m)) {
186
+                    return false;
187
+        }
177 188
 
178 189
         # 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;
190
+        if (in_array($m[1], array('AB', 'DD', 'EH', 'FK', 'G', 'HS', 'IV', 'KA', 'KW', 'KY', 'ML', 'PA', 'PH', 'ZE'))) {
191
+                    return true;
192
+        }
181 193
 
182 194
         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
195
+            if ($m[2]==16 && $m[3]==5 && in_array($m[4], array('HT','HU','HZ','JA','JB'))) {
196
+                return false;
197
+            }
198
+            # A few postcodes in England
184 199
             return true;
185 200
         }
186 201
 
187 202
         # Damn postcodes crossing country boundaries
188 203
         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
204
+            if ($m[2]!=15 && $m[2]!=12 && $m[2]!=9) {
205
+                return true;
206
+            }
207
+            # TD1-8, 10-11, 13-14 all in Scotland
190 208
             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
209
+                if ($m[3]!=0) {
210
+                    return true;
211
+                }
212
+                # TD9 1-9 all in Scotland
213
+                if (!in_array($m[4], array('TJ','TP','TR','TS','TT','TU','TW'))) {
214
+                    return true;
215
+                }
216
+                # Nearly all of TD9 0 in Scotland
193 217
             }
194 218
             $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
219
+            if ($m[2]==12) {
220
+# $m[3] will be 4 currently.
221
+                if ($m[4]=='XE') {
222
+                    return true;
223
+                }
224
+                if (in_array($m[5], array('A','B','D','E','H','J','L','N','W','Y'))) {
225
+                    return true;
226
+                }
227
+                # These bits of TD12 4 are in Scotland, others (Q, R, S, T, U, X) in England
198 228
             }
199 229
             # TD15 is mostly England
200 230
             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
231
+                if ($m[3]!=1) {
232
+                    return false;
233
+                }
234
+                # TD15 2 and 9 are in England
235
+                if (in_array($m[4], array('BT','SU','SZ','UF','UG','UH','UJ','UL','US','UZ','WY','WZ'))) {
236
+                    return true;
237
+                }
238
+                if ($m[5]=='T' && $m[4]!='TA' && $m[4]!='TB') {
239
+                    return true;
240
+                }
241
+                # Most of TD15 1T* in Scotland
242
+                if ($m[5]=='X' && $m[4]!='XX') {
243
+                    return true;
244
+                }
245
+                # TD15 1XX in England, rest of TD15 1X* in Scotland
205 246
             }
206 247
         }
207 248
 
@@ -215,8 +256,9 @@  discard block
 block discarded – undo
215 256
 
216 257
     public static function postcodeIsNi($pc) {
217 258
         $prefix = substr(self::canonicalisePostcode($pc), 0, 2);
218
-        if ($prefix == 'BT')
219
-            return true;
259
+        if ($prefix == 'BT') {
260
+                    return true;
261
+        }
220 262
         return false;
221 263
     }
222 264
 
Please login to merge, or discard this patch.