Failed Conditions
Pull Request — master (#1327)
by Nick
69:15 queued 59:17
created
tests/UtilityTest.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 
7 7
 class UtilityTest extends PHPUnit_Framework_TestCase
8 8
 {
9
-	public function setUp()
10
-	{
9
+    public function setUp()
10
+    {
11 11
         parent::setUp();
12 12
         include_once('www/includes/utility.php');
13 13
     }
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      * Test the escaping of replacement strings for use with
17 17
      * preg_replace.
18 18
      */
19
-	public function testPregReplacement()
19
+    public function testPregReplacement()
20 20
     {
21 21
         $example = 'try \1 and $0, also backslash \ and dollar $ alone';
22 22
         $this->assertEquals(
Please login to merge, or discard this patch.
tests/SectionTest.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 
19 19
     var $types = array('debates', 'whall', 'wrans', 'wms', 'ni', 'sp', 'spwrans', 'lords');
20 20
 
21
-	public function testDebatesFront() {
21
+    public function testDebatesFront() {
22 22
         foreach ($this->types as $type) {
23 23
             $this->fetch_page( array( 'type' => $type ) );
24 24
         }
25 25
     }
26 26
 
27
-	public function testDebatesYear() {
27
+    public function testDebatesYear() {
28 28
         foreach ($this->types as $type) {
29 29
             $page = $this->fetch_page( array( 'type' => $type, 'y' => '2014' ) );
30 30
             $this->assertContains('<div class="calendar">', $page);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         }
34 34
     }
35 35
 
36
-	public function testDebatesDay() {
36
+    public function testDebatesDay() {
37 37
         foreach ($this->types as $type) {
38 38
             $page = $this->fetch_page( array( 'type' => $type, 'd' => '2014-01-01' ) );
39 39
             $this->assertContains('Wednesday, 1 January 2014', $page);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
     }
55 55
 
56
-	public function testDebatesHeading() {
56
+    public function testDebatesHeading() {
57 57
         foreach ($this->types as $type) {
58 58
             if ($type == 'spwrans') {
59 59
                 # Only one level of headings on spwrans
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         }
71 71
     }
72 72
 
73
-	public function testDebatesSubheading() {
73
+    public function testDebatesSubheading() {
74 74
         foreach ($this->types as $type) {
75 75
             $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.2' ) );
76 76
             $this->assertContains("HeadingA", $page);
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
     }
101 101
 
102
-	public function testDebatesSpeech() {
102
+    public function testDebatesSpeech() {
103 103
         foreach ($this->types as $type) {
104 104
             $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) );
105 105
             if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 
21 21
 	public function testDebatesFront() {
22 22
         foreach ($this->types as $type) {
23
-            $this->fetch_page( array( 'type' => $type ) );
23
+            $this->fetch_page(array('type' => $type));
24 24
         }
25 25
     }
26 26
 
27 27
 	public function testDebatesYear() {
28 28
         foreach ($this->types as $type) {
29
-            $page = $this->fetch_page( array( 'type' => $type, 'y' => '2014' ) );
29
+            $page = $this->fetch_page(array('type' => $type, 'y' => '2014'));
30 30
             $this->assertContains('<div class="calendar">', $page);
31 31
             $this->assertContains('January', $page);
32 32
             $this->assertRegExp('/<td colspan="2">&nbsp;<\/td><td[^>]*><a href="\/' . $type . '\/\?d=2014-01-01">1<\/a><\/td><td[^>]*><span>2<\/span><\/td>/', $page);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	public function testDebatesDay() {
37 37
         foreach ($this->types as $type) {
38
-            $page = $this->fetch_page( array( 'type' => $type, 'd' => '2014-01-01' ) );
38
+            $page = $this->fetch_page(array('type' => $type, 'd' => '2014-01-01'));
39 39
             $this->assertContains('Wednesday, 1 January 2014', $page);
40 40
             $this->assertContains('HeadingA', $page);
41 41
             if ($type == 'wrans') {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                 continue;
61 61
             }
62 62
 
63
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.1' ) );
63
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.1'));
64 64
             if ($type == 'wrans') {
65 65
                 $this->assertRegexp("#All .*?written answers on 1 Jan 2014#i", $page);
66 66
                 $this->assertContains("QuestionA", $page);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	public function testDebatesSubheading() {
74 74
         foreach ($this->types as $type) {
75
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.2' ) );
75
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.2'));
76 76
             $this->assertContains("HeadingA", $page);
77 77
             if ($type == 'spwrans') {
78 78
                 $this->assertContains("QuestionA", $page);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	public function testDebatesSpeech() {
103 103
         foreach ($this->types as $type) {
104
-            $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) );
104
+            $page = $this->fetch_page(array('type' => $type, 'id' => '2014-01-01b.1.3'));
105 105
             if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') {
106 106
                 $this->assertRegexp("#Location: .*?/$type/\?id=2014-01-01b\.1\.2#", $page);
107 107
             } else {
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
      * @group xapian
126 126
      */
127 127
     public function testGlossaryAndSearchHighlights() {
128
-            $page = $this->fetch_page( array( 'type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3' ) );
128
+            $page = $this->fetch_page(array('type' => 'lords', 's' => 'constituency', 'id' => '2014-02-02b.1.3'));
129 129
             $this->assertContains("constituency", $page);
130 130
             $this->assertContains("<span class=\"hi\"><a href=\"/glossary/?gl=1\" title=\"In a general election, each Constituency chooses an MP to represent them....\" class=\"glossary\">constituency</a></span>", $page);
131 131
     }
132 132
 
133 133
     public function testGidRedirect() {
134
-        $page = $this->fetch_page( array( 'type' => 'wrans', 'id' => '2014-01-01a.187335.h' ) );
134
+        $page = $this->fetch_page(array('type' => 'wrans', 'id' => '2014-01-01a.187335.h'));
135 135
         $this->assertRegexp("#Location: .*?/wrans/\?id=2014-01-01b\.1\.2#", $page);
136 136
     }
137 137
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,12 +41,15 @@  discard block
 block discarded – undo
41 41
             if ($type == 'wrans') {
42 42
                 $this->assertContains('DepartmentA', $page);
43 43
                 $this->assertContains('QuestionA', $page);
44
-            } elseif ($type == 'spwrans') {
44
+            }
45
+            elseif ($type == 'spwrans') {
45 46
                 $this->assertContains('QuestionA', $page);
46
-            } elseif ($type == 'wms') {
47
+            }
48
+            elseif ($type == 'wms') {
47 49
                 $this->assertContains('DepartmentA', $page);
48 50
                 $this->assertContains('StatementA', $page);
49
-            } else {
51
+            }
52
+            else {
50 53
                 $this->assertContains('SubheadingA', $page);
51 54
                 $this->assertContains('SpeechA', $page);
52 55
             }
@@ -64,7 +67,8 @@  discard block
 block discarded – undo
64 67
             if ($type == 'wrans') {
65 68
                 $this->assertRegexp("#All .*?written answers on 1 Jan 2014#i", $page);
66 69
                 $this->assertContains("QuestionA", $page);
67
-            } else {
70
+            }
71
+            else {
68 72
                 $this->assertRegexp("#Location: .*?/$type/\?id=2014-01-01b\.1\.2#", $page);
69 73
             }
70 74
         }
@@ -77,7 +81,8 @@  discard block
 block discarded – undo
77 81
             if ($type == 'spwrans') {
78 82
                 $this->assertContains("QuestionA", $page);
79 83
                 $this->assertContains("AnswerA", $page);
80
-            } elseif ($type == 'wrans') {
84
+            }
85
+            elseif ($type == 'wrans') {
81 86
                 $this->assertContains("DepartmentA", $page);
82 87
                 $this->assertContains("QuestionA", $page);
83 88
                 $this->assertContains("AnswerA", $page);
@@ -86,10 +91,12 @@  discard block
 block discarded – undo
86 91
                 $this->assertContains('Mp2 Mp2', $page);
87 92
                 $this->assertContains('Birmingham', $page);
88 93
                 $this->assertContains('Independent', $page);
89
-            } elseif ($type == 'wms') {
94
+            }
95
+            elseif ($type == 'wms') {
90 96
                 $this->assertContains('DepartmentA', $page);
91 97
                 $this->assertContains('StatementA', $page);
92
-            } else {
98
+            }
99
+            else {
93 100
                 $this->assertContains("SubheadingA", $page);
94 101
                 $this->assertContains("SpeechA", $page);
95 102
             }
@@ -104,7 +111,8 @@  discard block
 block discarded – undo
104 111
             $page = $this->fetch_page( array( 'type' => $type, 'id' => '2014-01-01b.1.3' ) );
105 112
             if ($type == 'wrans' || $type == 'spwrans' || $type == 'wms') {
106 113
                 $this->assertRegexp("#Location: .*?/$type/\?id=2014-01-01b\.1\.2#", $page);
107
-            } else {
114
+            }
115
+            else {
108 116
                 $this->assertContains("HeadingA", $page);
109 117
                 $this->assertContains("SubheadingA", $page);
110 118
                 $this->assertContains("2:30 pm", $page);
Please login to merge, or discard this patch.
tests/SearchTest.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 
8 8
 class SearchTest extends FetchPageTestCase
9 9
 {
10
-	public function setUp()
11
-	{
10
+    public function setUp()
11
+    {
12 12
         parent::setUp();
13 13
         include_once('www/includes/easyparliament/searchengine.php');
14 14
     }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @group xapian
89 89
      */
90
-	public function testSearchNormal()
90
+    public function testSearchNormal()
91 91
     {
92 92
         $SEARCHENGINE = new SEARCHENGINE('test');
93 93
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @group xapian
104 104
      */
105
-	public function testSearchLink()
105
+    public function testSearchLink()
106 106
     {
107 107
         $SEARCHENGINE = new SEARCHENGINE('test');
108 108
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
     public function testConstituencySearch()
27 27
     {
28 28
         $this->assertEquals(
29
-            array( array( 'Alyn and Deeside' ), false ),
29
+            array(array('Alyn and Deeside'), false),
30 30
             \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn')
31 31
         );
32 32
         $this->assertEquals(
33
-            array( array( 'Alyn and Deeside' ), false ),
33
+            array(array('Alyn and Deeside'), false),
34 34
             \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn and Deeside')
35 35
         );
36 36
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function testSearchPage()
121 121
     {
122
-        $page = $this->fetch_page( array( ) );
122
+        $page = $this->fetch_page(array( ));
123 123
         $this->assertContains('Search', $page);
124 124
     }
125 125
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function testSearchPageMP()
132 132
     {
133
-        $page = $this->fetch_page( array( 'q' => 'Mary Smith' ) );
133
+        $page = $this->fetch_page(array('q' => 'Mary Smith'));
134 134
         $this->assertContains('Mary Smith', $page);
135 135
         $this->assertContains('MP, Amber Valley', $page);
136 136
     }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function testSearchPageMultipleMP()
144 144
     {
145
-        $page = $this->fetch_page( array( 'q' => 'Jones' ) );
145
+        $page = $this->fetch_page(array('q' => 'Jones'));
146 146
         $this->assertContains('People matching <em class="current-search-term">Jones</em>', $page);
147 147
         $this->assertContains('Andrew Jones', $page);
148 148
         $this->assertContains('Simon Jones', $page);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @group xapian
155 155
      */
156 156
     public function testSearchPageCons() {
157
-        $page = $this->fetch_page( array( 'q' => 'Amber' ) );
157
+        $page = $this->fetch_page(array('q' => 'Amber'));
158 158
         $this->assertContains('MP for <em class="current-search-term">Amber</em>', $page);
159 159
         $this->assertContains('Mary Smith', $page);
160 160
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @group xapian
167 167
      */
168 168
     public function testSearchPageConsWithNoMp() {
169
-        $page = $this->fetch_page( array( 'q' => 'Alyn' ) );
169
+        $page = $this->fetch_page(array('q' => 'Alyn'));
170 170
         $this->assertNotContains('MP for <em class="current-search-term">Alyn</em>', $page);
171 171
         $this->assertNotContains('MPs in constituencies matching', $page);
172 172
     }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @group xapian
179 179
      */
180 180
     public function testSearchPageMultipleCons() {
181
-        $page = $this->fetch_page( array( 'q' => 'Liverpool' ) );
181
+        $page = $this->fetch_page(array('q' => 'Liverpool'));
182 182
         $this->assertContains('MPs in constituencies matching <em class="current-search-term">Liverpool</em>', $page);
183 183
         $this->assertContains('Susan Brown', $page);
184 184
         $this->assertContains('MP, Liverpool, Riverside', $page);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      * @group xapian
193 193
      */
194 194
     public function testSearchPageGlossary() {
195
-        $page = $this->fetch_page( array( 'q' => 'other place' ) );
195
+        $page = $this->fetch_page(array('q' => 'other place'));
196 196
         $this->assertContains('Glossary items matching', $page);
197 197
         $this->assertContains('<a href="/glossary/?gl=1">&ldquo;other place', $page);
198 198
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @group xapian
204 204
      */
205 205
     public function testSearchPageSpellCorrect() {
206
-        $page = $this->fetch_page( array( 'q' => 'plice' ) );
206
+        $page = $this->fetch_page(array('q' => 'plice'));
207 207
         $this->assertContains('Did you mean <a href="/search/?q=place">place', $page);
208 208
     }
209 209
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @group xapian
214 214
      */
215 215
     public function testSearchBySpeakerNoResults() {
216
-        $page = $this->fetch_page( array( 'q' => 'splice', 'o' => 'p' ) );
216
+        $page = $this->fetch_page(array('q' => 'splice', 'o' => 'p'));
217 217
         $this->assertContains('Who says splice the most', $page);
218 218
         $this->assertContains('No results', $page);
219 219
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      * @group xapian
241 241
      */
242 242
     public function testSearchPageRSS() {
243
-        $page = $this->fetch_page( array( 'q' => 'test' ) );
243
+        $page = $this->fetch_page(array('q' => 'test'));
244 244
         $this->assertContains('<a href="/search/rss/?s=test">get an RSS feed', $page);
245 245
     }
246 246
 
Please login to merge, or discard this patch.
classes/Renderer.php 3 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.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
         // Find the user's country. Used by header, so a safe bit to do regardless.
30 30
         if (preg_match('#^[A-Z]{2}$#i', get_http_var('country'))) {
31 31
             $data['country'] = strtoupper(get_http_var('country'));
32
-        } else {
32
+        }
33
+        else {
33 34
             $data['country'] = Utility\Gaze::getCountryByIp($_SERVER["REMOTE_ADDR"]);
34 35
         }
35 36
 
@@ -85,7 +86,8 @@  discard block
 block discarded – undo
85 86
 
86 87
         if ($template_only) {
87 88
           require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
88
-        } else {
89
+        }
90
+        else {
89 91
           header('Content-Type: text/html; charset=utf-8');
90 92
           require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
91 93
           require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 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
 
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
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/Renderer/Footer.php 2 patches
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.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,8 @@  discard block
 block discarded – undo
51 51
             $menu = $DATA->page_metadata($page, 'menu');
52 52
             if ($menu) {
53 53
                 $title = $menu['text'];
54
-            } else {
54
+            }
55
+            else {
55 56
                 $title = $DATA->page_metadata($page, 'title');
56 57
             }
57 58
             $url = $DATA->page_metadata($page, 'url');
@@ -71,7 +72,8 @@  discard block
 block discarded – undo
71 72
                     'classes' => '',
72 73
                     'text'    => $title
73 74
                 );
74
-            } else {
75
+            }
76
+            else {
75 77
                 $links[] = array(
76 78
                     'href'    => $url,
77 79
                     'title'   => $tooltip,
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 4 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.
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.
Spacing   +18 added lines, -18 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
 
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
             $votes['against'] . ' ' . make_plural('vote', $votes['against']) . ' against'
285 285
         );
286 286
 
287
-        if ( $votes['both'] ) {
287
+        if ($votes['both']) {
288 288
             $actions[] = $votes['both'] . ' ' . make_plural('abstention', $votes['both']);
289 289
         }
290
-        if ( $votes['absent'] ) {
290
+        if ($votes['absent']) {
291 291
             $actions[] = $votes['absent'] . ' ' . make_plural('absence', $votes['absent']);
292 292
         }
293 293
         if ($max == $min) {
@@ -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);
@@ -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;
@@ -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.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -175,13 +175,17 @@  discard block
 block discarded – undo
175 175
           $policy_vote = str_replace('3', '', $q->field($n, 'policy_vote'));
176 176
           if ( $vote == 'absent' ) {
177 177
               $summary['absent'] += $q->field($n, 'total');
178
-          } else if ( $vote == 'both' ) {
178
+          }
179
+          else if ( $vote == 'both' ) {
179 180
               $summary['both'] += $q->field($n, 'total');
180
-          } else if ( strpos($vote, 'tell') !== FALSE ) {
181
+          }
182
+          else if ( strpos($vote, 'tell') !== FALSE ) {
181 183
               $summary['tell'] += $q->field($n, 'total');
182
-          } else if ( $policy_vote == $vote ) {
184
+          }
185
+          else if ( $policy_vote == $vote ) {
183 186
               $summary['for'] += $q->field($n, 'total');
184
-          } else if ( $policy_vote != $vote ) {
187
+          }
188
+          else if ( $policy_vote != $vote ) {
185 189
               $summary['against'] += $q->field($n, 'total');
186 190
           }
187 191
 
@@ -238,11 +242,14 @@  discard block
 block discarded – undo
238 242
 
239 243
             if ($vote['vote'] == 'aye' or $vote['vote'] == 'tellaye') {
240 244
               $votes['yes_votes'][] = $detail;
241
-            } else if ($vote['vote'] == 'no' or $vote['vote'] == 'tellno') {
245
+            }
246
+            else if ($vote['vote'] == 'no' or $vote['vote'] == 'tellno') {
242 247
               $votes['no_votes'][] = $detail;
243
-            } else if ($vote['vote'] == 'absent') {
248
+            }
249
+            else if ($vote['vote'] == 'absent') {
244 250
               $votes['absent_votes'][] = $detail;
245
-            } else if ($vote['vote'] == 'both') {
251
+            }
252
+            else if ($vote['vote'] == 'both') {
246 253
               $votes['both_votes'][] = $detail;
247 254
             }
248 255
 
@@ -292,7 +299,8 @@  discard block
 block discarded – undo
292 299
         }
293 300
         if ($max == $min) {
294 301
             return join(', ', $actions) . ', in ' . $max;
295
-        } else {
302
+        }
303
+        else {
296 304
             return join(', ', $actions) . ', between ' . $min . '&ndash;' . $max;
297 305
         }
298 306
     }
@@ -340,7 +348,8 @@  discard block
 block discarded – undo
340 348
         for ($n = 0; $n < $row_count; $n++) {
341 349
           if ($context == 'Parliament') {
342 350
               $divisions[] = $this->getParliamentDivisionDetails($q->row($n));
343
-          } else {
351
+          }
352
+          else {
344 353
               $divisions[] = $this->getDivisionDetails($q->row($n));
345 354
           }
346 355
         }
@@ -353,7 +362,8 @@  discard block
 block discarded – undo
353 362
         $text = ' voted ';
354 363
         if ( $short_text ) {
355 364
             $text .= $short_text;
356
-        } else {
365
+        }
366
+        else {
357 367
             $text .= "$direction on <em>$title</em>";
358 368
         }
359 369
 
@@ -401,7 +411,8 @@  discard block
 block discarded – undo
401 411
         $direction = $row['direction'];
402 412
         if ( strpos( $direction, 'strong') !== FALSE ) {
403 413
             $division['strong'] = TRUE;
404
-        } else {
414
+        }
415
+        else {
405 416
             $division['strong'] = FALSE;
406 417
         }
407 418
 
@@ -447,7 +458,8 @@  discard block
 block discarded – undo
447 458
           $mp_vote = ' was absent';
448 459
           if ($row['vote'] == 'aye') {
449 460
               $mp_vote = 'voted in favour';
450
-          } else if ($row['vote'] == 'no') {
461
+          }
462
+          else if ($row['vote'] == 'no') {
451 463
               $mp_vote = 'voted against';
452 464
           }
453 465
           $division['mp_vote'] = $mp_vote;
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.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $both = 1;
220 220
         $agree = 10;
221 221
 
222
-        if ( stripos($vote, '3') !== FALSE ) {
222
+        if ( stripos($vote, '3') !== false ) {
223 223
             $agree = 50;
224 224
             $absent = 25;
225 225
             $both = 25;
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             'both' => $both
231 231
         );
232 232
 
233
-        if ( stripos($vote, 'aye') !== FALSE ) {
233
+        if ( stripos($vote, 'aye') !== false ) {
234 234
             $scores['aye'] = $agree;
235 235
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
236
+        } else if ( stripos($vote, 'no') !== false ) {
237 237
             $scores['no'] = $agree;
238 238
             $scores['aye'] = 0;
239 239
         } else {
Please login to merge, or discard this patch.
Braces   +23 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
         if ( $member_count->rows ) {
46 46
             $num_members = $member_count->field(0, 'num_members');
47 47
             return $num_members;
48
-        } else {
48
+        }
49
+        else {
49 50
             return 0;
50 51
         }
51 52
     }
@@ -76,10 +77,12 @@  discard block
 block discarded – undo
76 77
 
77 78
             if ( $want_score ) {
78 79
                 return array( $score_desc, $score);
79
-            } else {
80
+            }
81
+            else {
80 82
                 return $score_desc;
81 83
             }
82
-        } else {
84
+        }
85
+        else {
83 86
             return null;
84 87
         }
85 88
     }
@@ -144,9 +147,15 @@  discard block
 block discarded – undo
144 147
             $num_votes = 0;
145 148
             for ( $j = 0; $j < $votes->rows(); $j++ ) {
146 149
                 $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';
150
+                if ( $vote_dir == '' ) {
151
+                    continue;
152
+                }
153
+                if ( $vote_dir == 'tellno' ) {
154
+                    $vote_dir = 'no';
155
+                }
156
+                if ( $vote_dir == 'tellaye' ) {
157
+                    $vote_dir = 'aye';
158
+                }
150 159
 
151 160
                 $num_votes += $votes->field($j, 'num_votes');
152 161
                 $score += ($votes->field($j, 'num_votes') * $weights[$vote_dir]);
@@ -165,14 +174,16 @@  discard block
 block discarded – undo
165 174
         // really say what the parties position is.
166 175
         if ( $max_score == 0 ) {
167 176
             $weight = -1;
168
-        } else {
177
+        }
178
+        else {
169 179
             $weight = 1 - ( $score/$max_score );
170 180
         }
171 181
         $score_desc = score_to_strongly($weight);
172 182
 
173 183
         if ( $want_score ) {
174 184
             return array( $score_desc, $weight);
175
-        } else {
185
+        }
186
+        else {
176 187
             return $score_desc;
177 188
         }
178 189
     }
@@ -233,10 +244,12 @@  discard block
 block discarded – undo
233 244
         if ( stripos($vote, 'aye') !== FALSE ) {
234 245
             $scores['aye'] = $agree;
235 246
             $scores['no'] = 0;
236
-        } else if ( stripos($vote, 'no') !== FALSE ) {
247
+        }
248
+        else if ( stripos($vote, 'no') !== FALSE ) {
237 249
             $scores['no'] = $agree;
238 250
             $scores['aye'] = 0;
239
-        } else {
251
+        }
252
+        else {
240 253
             $scores['both'] = 0;
241 254
             $scores['absent'] = 0;
242 255
             $scores['no'] = 0;
Please login to merge, or discard this patch.
classes/Office.php 4 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
     public $source;
20 20
 
21 21
     /**
22
-    * To String
23
-    *
24
-    * Return the office title as a string.
25
-    *
26
-    * @return string The title of the office, or "Unnamed Office"
27
-    */
22
+     * To String
23
+     *
24
+     * Return the office title as a string.
25
+     *
26
+     * @return string The title of the office, or "Unnamed Office"
27
+     */
28 28
 
29 29
     public function __toString() {
30 30
         if (isset ($this->title)){
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     /**
38
-    * Pretty Dates
39
-    *
40
-    * Return a string containing prettified dates of this office.
41
-    *
42
-    * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the
43
-    * old selctee/privsec pages on parliament.uk (you can see this in
44
-    * cmpages/chgpages' privsec0001_2004-06-08.html and
45
-    * selctee0001_2004-06-08.html). So if the date is those dates for those two
46
-    * things, you don't want to display it because it's not a known start date,
47
-    * it could have been before that date. 2005-11-10 is because the PPS changes
48
-    * did not all happen on that date but the website did not update until that
49
-    * date so it outputs "before" in either from/to date in that case.
50
-    * 2009-01-16 is the last date before the page disappeared off parliament.uk
51
-    * entirely so that displays that fact that after then we don't know.
52
-    *
53
-    * @todo https://github.com/mysociety/theyworkforyou/issues/632
54
-    *
55
-    * @return string The dates of this office in a readable form.
56
-    */
38
+     * Pretty Dates
39
+     *
40
+     * Return a string containing prettified dates of this office.
41
+     *
42
+     * 2004-05-28 and 2004-05-13 are the first dates for data scraped from the
43
+     * old selctee/privsec pages on parliament.uk (you can see this in
44
+     * cmpages/chgpages' privsec0001_2004-06-08.html and
45
+     * selctee0001_2004-06-08.html). So if the date is those dates for those two
46
+     * things, you don't want to display it because it's not a known start date,
47
+     * it could have been before that date. 2005-11-10 is because the PPS changes
48
+     * did not all happen on that date but the website did not update until that
49
+     * date so it outputs "before" in either from/to date in that case.
50
+     * 2009-01-16 is the last date before the page disappeared off parliament.uk
51
+     * entirely so that displays that fact that after then we don't know.
52
+     *
53
+     * @todo https://github.com/mysociety/theyworkforyou/issues/632
54
+     *
55
+     * @return string The dates of this office in a readable form.
56
+     */
57 57
 
58 58
     public function pretty_dates() {
59 59
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         $output = '';
65 65
 
66 66
         if (
67
-            !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') AND
67
+            !($this->source == 'chgpages/selctee' && $this->from_date == '2004-05-28') and
68 68
             !($this->source == 'chgpages/privsec' && $this->from_date == '2004-05-13')
69 69
         ) {
70 70
             if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     */
28 28
 
29 29
     public function __toString() {
30
-        if (isset ($this->title)){
30
+        if (isset ($this->title)) {
31 31
             return (string) $this->title;
32 32
         } else {
33 33
             return 'Unnamed Office';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             if ($this->source == 'chgpages/privsec' && $this->from_date == '2005-11-10') {
71 71
                 $output .= 'before ';
72 72
             }
73
-            $output .= format_date($this->from_date,SHORTDATEFORMAT) . ' ';
73
+            $output .= format_date($this->from_date, SHORTDATEFORMAT) . ' ';
74 74
         }
75 75
 
76 76
         $output .= 'to ';
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,9 +27,10 @@  discard block
 block discarded – undo
27 27
     */
28 28
 
29 29
     public function __toString() {
30
-        if (isset ($this->title)){
30
+        if (isset ($this->title)) {
31 31
             return (string) $this->title;
32
-        } else {
32
+        }
33
+        else {
33 34
             return 'Unnamed Office';
34 35
         }
35 36
     }
@@ -81,7 +82,8 @@  discard block
 block discarded – undo
81 82
 
82 83
         if ($this->source == 'chgpages/privsec' && $this->to_date == '2009-01-16') {
83 84
             $output .= '<a href="/help/#pps_unknown">unknown</a>';
84
-        } else {
85
+        }
86
+        else {
85 87
             $output .= format_date($this->to_date, SHORTDATEFORMAT);
86 88
         }
87 89
 
Please login to merge, or discard this patch.