@@ -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; |
| 4 | 4 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @param LoggerInterface $logger |
| 29 | 29 | * @param string $domain The URL of the wiki, if different from default |
| 30 | 30 | */ |
| 31 | - public function __construct( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
| 31 | + public function __construct ( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
| 32 | 32 | $this->logger = $logger; |
| 33 | 33 | $this->domain = $domain; |
| 34 | 34 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @throws MissingPageException |
| 43 | 43 | * @throws MissingSectionException |
| 44 | 44 | */ |
| 45 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 45 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 46 | 46 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
| 47 | 47 | $this->logger->debug( $msg ); |
| 48 | 48 | $params = [ |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | ]; |
| 55 | 55 | |
| 56 | 56 | if ( $section !== null ) { |
| 57 | - $params['rvsection'] = $section; |
|
| 57 | + $params[ 'rvsection' ] = $section; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $req = $this->buildRequest( $params ); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | throw new MissingPageException( $title ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 67 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 68 | 68 | |
| 69 | 69 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 70 | 70 | throw new MissingSectionException( $title, $section ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param array $params |
| 79 | 79 | * @throws EditException |
| 80 | 80 | */ |
| 81 | - public function editPage( array $params ) { |
|
| 81 | + public function editPage ( array $params ) { |
|
| 82 | 82 | $this->login(); |
| 83 | 83 | |
| 84 | 84 | $params = [ |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | ] + $params; |
| 88 | 88 | |
| 89 | 89 | if ( Config::getInstance()->get( 'bot-edits' ) ) { |
| 90 | - $params['bot'] = 1; |
|
| 90 | + $params[ 'bot' ] = 1; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 106 | 106 | * @throws LoginException |
| 107 | 107 | */ |
| 108 | - public function login() { |
|
| 108 | + public function login () { |
|
| 109 | 109 | if ( self::$loggedIn ) { |
| 110 | 110 | return; |
| 111 | 111 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | self::$loggedIn = true; |
| 134 | 134 | // Clear tokens cache |
| 135 | - $this->tokens = []; |
|
| 135 | + $this->tokens = [ ]; |
|
| 136 | 136 | $this->logger->info( 'Login succeeded' ); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string $type |
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | - public function getToken( string $type ) : string { |
|
| 145 | + public function getToken ( string $type ) : string { |
|
| 146 | 146 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 147 | 147 | $params = [ |
| 148 | 148 | 'action' => 'query', |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $title |
| 166 | 166 | * @return int |
| 167 | 167 | */ |
| 168 | - public function getPageCreationTS( string $title ) : int { |
|
| 168 | + public function getPageCreationTS ( string $title ) : int { |
|
| 169 | 169 | $params = [ |
| 170 | 170 | 'action' => 'query', |
| 171 | 171 | 'prop' => 'revisions', |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $res = $this->buildRequest( $params )->execute(); |
| 180 | 180 | $data = $res->query->pages; |
| 181 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 181 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param string $title |
| 188 | 188 | * @param string $reason |
| 189 | 189 | */ |
| 190 | - public function protectPage( string $title, string $reason ) { |
|
| 190 | + public function protectPage ( string $title, string $reason ) { |
|
| 191 | 191 | $this->logger->info( "Protecting page $title" ); |
| 192 | 192 | $this->login(); |
| 193 | 193 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param array $params |
| 209 | 209 | * @return RequestBase |
| 210 | 210 | */ |
| 211 | - private function buildRequest( array $params ) : RequestBase { |
|
| 211 | + private function buildRequest ( array $params ) : RequestBase { |
|
| 212 | 212 | return RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
| 213 | 213 | } |
| 214 | 214 | } |