| @@ -1,4 +1,4 @@ discard block | ||
| 1 | -<?php declare( strict_types=1 ); | |
| 1 | +<?php declare(strict_types=1); | |
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki\Page; | 
| 4 | 4 | |
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | /** @var int */ | 
| 15 | 15 | private $opposeSection; | 
| 16 | 16 | /** @var array Counts of votes for each section */ | 
| 17 | - private $sectionCounts = []; | |
| 17 | + private $sectionCounts = [ ]; | |
| 18 | 18 | |
| 19 | 19 | // Possible outcomes of a vote | 
| 20 | 20 | public const OUTCOME_OK = 0; | 
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 | * because they can vary depending on whether the page is a vote, which is relatively | 
| 34 | 34 | * expensive to know since it requires parsing the content of the page. | 
| 35 | 35 | */ | 
| 36 | -	private function defineSections() : void { | |
| 36 | +	private function defineSections () : void { | |
| 37 | 37 | $this->supportSection = $this->isVote() ? 3 : 0; | 
| 38 | 38 | $this->opposeSection = $this->isVote() ? 4 : 3; | 
| 39 | 39 | } | 
| @@ -43,8 +43,8 @@ discard block | ||
| 43 | 43 | * | 
| 44 | 44 | * @return string | 
| 45 | 45 | */ | 
| 46 | -	public function getUserName() : string { | |
| 47 | - return explode( '/', $this->title )[2]; | |
| 46 | +	public function getUserName () : string { | |
| 47 | + return explode( '/', $this->title )[ 2 ]; | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | /** | 
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 | * | 
| 53 | 53 | * @return int | 
| 54 | 54 | */ | 
| 55 | -	public function getNum() : int { | |
| 55 | +	public function getNum () : int { | |
| 56 | 56 | $bits = explode( '/', $this->getTitle() ); | 
| 57 | 57 | return (int)end( $bits ); | 
| 58 | 58 | } | 
| @@ -62,8 +62,8 @@ discard block | ||
| 62 | 62 | * | 
| 63 | 63 | * @return string | 
| 64 | 64 | */ | 
| 65 | -	public function getUserNum() : string { | |
| 66 | - return explode( '/', $this->getTitle(), 3 )[2]; | |
| 65 | +	public function getUserNum () : string { | |
| 66 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; | |
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | 69 | /** | 
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 | * | 
| 72 | 72 | * @return int | 
| 73 | 73 | */ | 
| 74 | -	public function getOpposingCount() : int { | |
| 74 | +	public function getOpposingCount () : int { | |
| 75 | 75 | $this->defineSections(); | 
| 76 | 76 | return $this->getCountForSection( $this->opposeSection ); | 
| 77 | 77 | } | 
| @@ -82,7 +82,7 @@ discard block | ||
| 82 | 82 | * @return int | 
| 83 | 83 | * @throws \BadMethodCallException | 
| 84 | 84 | */ | 
| 85 | -	public function getSupportCount() : int { | |
| 85 | +	public function getSupportCount () : int { | |
| 86 | 86 |  		if ( !$this->isVote() ) { | 
| 87 | 87 | throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' ); | 
| 88 | 88 | } | 
| @@ -96,13 +96,13 @@ discard block | ||
| 96 | 96 | * @param int $secNum | 
| 97 | 97 | * @return int | 
| 98 | 98 | */ | 
| 99 | -	protected function getCountForSection( int $secNum ) : int { | |
| 99 | +	protected function getCountForSection ( int $secNum ) : int { | |
| 100 | 100 |  		if ( !isset( $this->sectionCounts[ $secNum ] ) ) { | 
| 101 | 101 | $content = $this->wiki->getPageContent( $this->title, $secNum ); | 
| 102 | 102 | // Let's hope that this is good enough... | 
| 103 | - $this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); | |
| 103 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); | |
| 104 | 104 | } | 
| 105 | - return $this->sectionCounts[$secNum]; | |
| 105 | + return $this->sectionCounts[ $secNum ]; | |
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | /** | 
| @@ -110,9 +110,9 @@ discard block | ||
| 110 | 110 | * | 
| 111 | 111 | * @return int | 
| 112 | 112 | */ | 
| 113 | -	protected function getQuorum() : int { | |
| 113 | +	protected function getQuorum () : int { | |
| 114 | 114 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; | 
| 115 | - return (int)$this->getMatch( $reg )[1]; | |
| 115 | + return (int)$this->getMatch( $reg )[ 1 ]; | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | /** | 
| @@ -120,7 +120,7 @@ discard block | ||
| 120 | 120 | * | 
| 121 | 121 | * @return bool | 
| 122 | 122 | */ | 
| 123 | -	public function hasOpposition() : bool { | |
| 123 | +	public function hasOpposition () : bool { | |
| 124 | 124 | return $this->getOpposingCount() >= self::REQUIRED_OPPOSE; | 
| 125 | 125 | } | 
| 126 | 126 | |
| @@ -129,7 +129,7 @@ discard block | ||
| 129 | 129 | * | 
| 130 | 130 | * @return int One of the OUTCOME_* constants | 
| 131 | 131 | */ | 
| 132 | -	public function getOutcome() : int { | |
| 132 | +	public function getOutcome () : int { | |
| 133 | 133 |  		if ( !$this->isVote() ) { | 
| 134 | 134 | return self::OUTCOME_OK; | 
| 135 | 135 | } | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 | * @throws \BadMethodCallException | 
| 153 | 153 | * @throws \LogicException | 
| 154 | 154 | */ | 
| 155 | -	public function getOutcomeText() : string { | |
| 155 | +	public function getOutcomeText () : string { | |
| 156 | 156 |  		if ( !$this->isVote() ) { | 
| 157 | 157 | throw new \BadMethodCallException( 'No need for an outcome text.' ); | 
| 158 | 158 | } | 
| @@ -186,7 +186,7 @@ discard block | ||
| 186 | 186 | * | 
| 187 | 187 | * @return bool | 
| 188 | 188 | */ | 
| 189 | -	public function isVote() : bool { | |
| 189 | +	public function isVote () : bool { | |
| 190 | 190 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; | 
| 191 | 191 | return !$this->matches( $sectionReg ); | 
| 192 | 192 | } | 
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 | * | 
| 197 | 197 | * @return int | 
| 198 | 198 | */ | 
| 199 | -	public function getCreationTimestamp() : int { | |
| 199 | +	public function getCreationTimestamp () : int { | |
| 200 | 200 | return $this->wiki->getPageCreationTS( $this->title ); | 
| 201 | 201 | } | 
| 202 | 202 | |
| @@ -205,7 +205,7 @@ discard block | ||
| 205 | 205 | * | 
| 206 | 206 | * @return int | 
| 207 | 207 | */ | 
| 208 | -	public function getEndTimestamp() : int { | |
| 208 | +	public function getEndTimestamp () : int { | |
| 209 | 209 |  		if ( $this->isVote() ) { | 
| 210 | 210 | $reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!"; | 
| 211 | 211 | [ , $hours, $day ] = $this->getMatch( $reg ); |