Passed
Push — master ( d4dbe0...881cd9 )
by Daimona
10:37
created
src/Wiki/Page/PageRiconferma.php 1 patch
Spacing   +21 added lines, -21 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\Wiki\Page;
4 4
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/** @var int|null */
17 17
 	private $opposeSection;
18 18
 	/** @var int[] Counts of votes for each section */
19
-	private $sectionCounts = [];
19
+	private $sectionCounts = [ ];
20 20
 
21 21
 	// Possible outcomes of a vote
22 22
 	public const OUTCOME_OK = 0;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * because they can vary depending on whether the page is a vote, which is relatively
37 37
 	 * expensive to know since it requires parsing the content of the page.
38 38
 	 */
39
-	private function defineSections(): void {
39
+	private function defineSections (): void {
40 40
 		$this->supportSection = $this->isVote() ? 3 : 0;
41 41
 		$this->opposeSection = $this->isVote() ? 4 : 3;
42 42
 	}
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return string
48 48
 	 */
49
-	public function getUserName(): string {
50
-		return explode( '/', $this->title )[2];
49
+	public function getUserName (): 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 (int)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 int
76 76
 	 */
77
-	public function getOpposingCount(): int {
77
+	public function getOpposingCount (): int {
78 78
 		$this->defineSections();
79 79
 		return $this->getCountForSection( $this->opposeSection );
80 80
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return int
86 86
 	 * @throws BadMethodCallException
87 87
 	 */
88
-	public function getSupportCount(): int {
88
+	public function getSupportCount (): int {
89 89
 		if ( !$this->isVote() ) {
90 90
 			throw new BadMethodCallException( 'Cannot get support for a non-vote page.' );
91 91
 		}
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @param int $secNum
100 100
 	 * @return int
101 101
 	 */
102
-	protected function getCountForSection( int $secNum ): int {
102
+	protected function getCountForSection ( int $secNum ): int {
103 103
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
104 104
 			$content = $this->wiki->getPageContent( $this->title, $secNum );
105 105
 			// Let's hope that this is good enough...
106
-			$this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
106
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
107 107
 		}
108
-		return $this->sectionCounts[$secNum];
108
+		return $this->sectionCounts[ $secNum ];
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return int
115 115
 	 */
116
-	protected function getQuorum(): int {
116
+	protected function getQuorum (): int {
117 117
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
118
-		return (int)$this->getMatch( $reg )[1];
118
+		return (int)$this->getMatch( $reg )[ 1 ];
119 119
 	}
120 120
 
121 121
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @return bool
125 125
 	 */
126
-	public function hasOpposition(): bool {
126
+	public function hasOpposition (): bool {
127 127
 		$req = min(
128 128
 			self::REQUIRED_OPPOSE_MAX,
129 129
 			ceil( $this->getQuorum() * self::REQUIRED_OPPOSE_QUORUM_RATIO )
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return int One of the OUTCOME_* constants
138 138
 	 */
139
-	public function getOutcome(): int {
139
+	public function getOutcome (): int {
140 140
 		if ( !$this->isVote() ) {
141 141
 			return self::OUTCOME_OK;
142 142
 		}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @throws BadMethodCallException
160 160
 	 * @throws LogicException
161 161
 	 */
162
-	public function getOutcomeText(): string {
162
+	public function getOutcomeText (): string {
163 163
 		if ( !$this->isVote() ) {
164 164
 			throw new BadMethodCallException( 'No need for an outcome text.' );
165 165
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return bool
195 195
 	 */
196
-	public function isVote(): bool {
196
+	public function isVote (): bool {
197 197
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
198 198
 		return !$this->matches( $sectionReg );
199 199
 	}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return int
205 205
 	 */
206
-	public function getCreationTimestamp(): int {
206
+	public function getCreationTimestamp (): int {
207 207
 		return $this->wiki->getPageCreationTS( $this->title );
208 208
 	}
209 209
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return int
214 214
 	 */
215
-	public function getEndTimestamp(): int {
215
+	public function getEndTimestamp (): int {
216 216
 		if ( $this->isVote() ) {
217 217
 			$reg = "!La votazione ha inizio il.+ e ha termine il (\d+ \w+ \d+) alle ([\d:]+)!";
218 218
 			[ , $day, $hours ] = $this->getMatch( $reg );
Please login to merge, or discard this patch.