Passed
Push — master ( 2e7fdd...aa5487 )
by Daimona
01:38
created
includes/PageRiconferma.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string $title
30 30
 	 * @param WikiController $controller
31 31
 	 */
32
-	public function __construct( string $title, WikiController $controller ) {
32
+	public function __construct ( string $title, WikiController $controller ) {
33 33
 		$this->title = $title;
34 34
 		$this->controller = $controller;
35 35
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @return string
39 39
 	 */
40
-	public function getTitle() : string {
40
+	public function getTitle () : string {
41 41
 		return $this->title;
42 42
 	}
43 43
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return string
48 48
 	 */
49
-	public function getUser() : string {
50
-		return explode( '/', $this->title )[2];
49
+	public function getUser () : string {
50
+		return explode( '/', $this->title )[ 2 ];
51 51
 	}
52 52
 
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return int
57 57
 	 */
58
-	public function getNum() : int {
58
+	public function getNum () : int {
59 59
 		$bits = explode( '/', $this->getTitle() );
60 60
 		return intval( end( $bits ) );
61 61
 	}
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return string
67 67
 	 */
68
-	public function getUserNum() : string {
69
-		return explode( '/', $this->getTitle(), 3 )[2];
68
+	public function getUserNum () : string {
69
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
70 70
 	}
71 71
 
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return string
76 76
 	 */
77
-	public function getBaseTitle() : string {
77
+	public function getBaseTitle () : string {
78 78
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
79 79
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
80 80
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return string
86 86
 	 */
87
-	public function getContent() : string {
87
+	public function getContent () : string {
88 88
 		if ( $this->content === null ) {
89 89
 			$this->content = $this->controller->getPageContent( $this->title );
90 90
 		}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return int
98 98
 	 */
99
-	public function getOpposingCount() : int {
99
+	public function getOpposingCount () : int {
100 100
 		return $this->getCountForSection( self::SECTION_OPPOSE );
101 101
 	}
102 102
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return int
107 107
 	 */
108
-	public function getSupportCount() : int {
108
+	public function getSupportCount () : int {
109 109
 		return $this->getCountForSection( self::SECTION_SUPPORT );
110 110
 	}
111 111
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @param int $secNum
116 116
 	 * @return int
117 117
 	 */
118
-	protected function getCountForSection( int $secNum ) : int {
118
+	protected function getCountForSection ( int $secNum ) : int {
119 119
 		$params = [
120 120
 			'action' => 'query',
121 121
 			'prop' => 'revisions',
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$res = RequestBase::newFromParams( $params )->execute();
129 129
 		$page = reset( $res->query->pages );
130
-		$content = $page->revisions[0]->slots->main->{ '*' };
130
+		$content = $page->revisions[ 0 ]->slots->main->{ '*' };
131 131
 		// Let's hope that this is good enough...
132 132
 		return substr_count( $content, "\n\# *(?![#*])" );
133 133
 	}
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return int
139 139
 	 */
140
-	protected function getQuorum() : int {
140
+	protected function getQuorum () : int {
141 141
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
142
-		$matches = [];
142
+		$matches = [ ];
143 143
 		preg_match( $reg, $this->getContent(), $matches );
144
-		return intval( $matches[1] );
144
+		return intval( $matches[ 1 ] );
145 145
 	}
146 146
 
147 147
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return bool
151 151
 	 */
152
-	public function hasOpposition() : bool {
152
+	public function hasOpposition () : bool {
153 153
 		return $this->getOpposingCount() >= 15;
154 154
 	}
155 155
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @return int One of the OUTCOME_* constants
160 160
 	 * @throws \BadMethodCallException
161 161
 	 */
162
-	public function getOutcome() : int {
162
+	public function getOutcome () : int {
163 163
 		if ( !$this->isVote() ) {
164 164
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
165 165
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return string
179 179
 	 * @throws \BadMethodCallException
180 180
 	 */
181
-	public function getOutcomeText() : string {
181
+	public function getOutcomeText () : string {
182 182
 		if ( !$this->isVote() ) {
183 183
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
184 184
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @return bool
212 212
 	 */
213
-	public function isVote() : bool {
213
+	public function isVote () : bool {
214 214
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
215 215
 		return preg_match( $sectionReg, $this->getContent() ) === false;
216 216
 	}
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return int
222 222
 	 */
223
-	public function getEndTimestamp() : int {
223
+	public function getEndTimestamp () : int {
224 224
 		if ( $this->isVote() ) {
225
-			$matches = [];
225
+			$matches = [ ];
226 226
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
227 227
 			preg_match( $reg, $this->getContent(), $matches );
228 228
 			list( , $day, $hours ) = $matches;
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @param array $params
241 241
 	 */
242
-	public function edit( array $params ) {
242
+	public function edit ( array $params ) {
243 243
 		$params = [
244 244
 			'title' => $this->getTitle()
245 245
 		] + $params;
246 246
 
247 247
 		$this->controller->editPage( $params );
248
-		if ( isset( $params['text'] ) ) {
249
-			$this->content = $params['text'];
250
-		} elseif ( isset( $params['appendtext'] ) ) {
251
-			$this->content .= $params['appendtext'];
248
+		if ( isset( $params[ 'text' ] ) ) {
249
+			$this->content = $params[ 'text' ];
250
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
251
+			$this->content .= $params[ 'appendtext' ];
252 252
 		}
253 253
 	}
254
-	public function __toString() {
254
+	public function __toString () {
255 255
 		return $this->getTitle();
256 256
 	}
257 257
 }
Please login to merge, or discard this patch.