Passed
Push — master ( 393b08...0ea8f2 )
by Daimona
08:52
created
includes/Wiki/Page/Page.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param string $title
23 23
 	 * @param string $domain The site where the page lives, if different from default
24 24
 	 */
25
-	public function __construct( string $title, string $domain = DEFAULT_URL ) {
25
+	public function __construct ( string $title, string $domain = DEFAULT_URL ) {
26 26
 		$this->title = $title;
27 27
 		$this->controller = new Controller( $domain );
28 28
 	}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @return string
32 32
 	 */
33
-	public function getTitle() : string {
33
+	public function getTitle () : string {
34 34
 		return $this->title;
35 35
 	}
36 36
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param int|null $section A section number to retrieve the content of that section
41 41
 	 * @return string
42 42
 	 */
43
-	public function getContent( int $section = null ) : string {
43
+	public function getContent ( int $section = null ) : string {
44 44
 		if ( $this->content === null ) {
45 45
 			$this->content = $this->controller->getPageContent( $this->title, $section );
46 46
 		}
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 	 * @param array $params
54 54
 	 * @throws \LogicException
55 55
 	 */
56
-	public function edit( array $params ) {
56
+	public function edit ( array $params ) {
57 57
 		$params = [
58 58
 			'title' => $this->getTitle()
59 59
 		] + $params;
60 60
 
61 61
 		$this->controller->editPage( $params );
62
-		if ( isset( $params['text'] ) ) {
63
-			$this->content = $params['text'];
64
-		} elseif ( isset( $params['appendtext'] ) ) {
65
-			$this->content .= $params['appendtext'];
66
-		} elseif ( isset( $params['prependtext'] ) ) {
67
-			$this->content = $params['prependtext'] . $this->content;
62
+		if ( isset( $params[ 'text' ] ) ) {
63
+			$this->content = $params[ 'text' ];
64
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
65
+			$this->content .= $params[ 'appendtext' ];
66
+		} elseif ( isset( $params[ 'prependtext' ] ) ) {
67
+			$this->content = $params[ 'prependtext' ] . $this->content;
68 68
 		} else {
69 69
 			throw new \LogicException(
70 70
 				'Unrecognized text param for edit. Params: ' . var_export( $params, true )
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return bool
79 79
 	 */
80
-	public function exists() : bool {
80
+	public function exists () : bool {
81 81
 		$res = RequestBase::newFromParams( [
82 82
 			'action' => 'query',
83 83
 			'titles' => $this->getTitle()
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @param string $regex
93 93
 	 * @return bool
94 94
 	 */
95
-	public function matches( string $regex ) : bool {
95
+	public function matches ( string $regex ) : bool {
96 96
 		return (bool)preg_match( $regex, $this->getContent() );
97 97
 	}
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @return string[]
105 105
 	 * @throws \Exception
106 106
 	 */
107
-	public function getMatch( string $regex ) : array {
108
-		$ret = [];
107
+	public function getMatch ( string $regex ) : array {
108
+		$ret = [ ];
109 109
 		if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) {
110 110
 			throw new \Exception( 'The content does not match the given regex' );
111 111
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @inheritDoc
119 119
 	 */
120
-	public function getRegex() : string {
120
+	public function getRegex () : string {
121 121
 		return str_replace( ' ', '[ _]', preg_quote( $this->title ) );
122 122
 	}
123 123
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string
128 128
 	 */
129
-	public function __toString() {
129
+	public function __toString () {
130 130
 		return $this->getTitle();
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.
includes/Wiki/Controller.php 1 patch
Spacing   +13 added lines, -13 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;
4 4
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $domain The URL of the wiki, if different from default
29 29
 	 */
30
-	public function __construct( string $domain = DEFAULT_URL ) {
30
+	public function __construct ( string $domain = DEFAULT_URL ) {
31 31
 		$this->logger = new Logger;
32 32
 		$this->domain = $domain;
33 33
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @throws MissingPageException
42 42
 	 * @throws MissingSectionException
43 43
 	 */
44
-	public function getPageContent( string $title, int $section = null ) : string {
44
+	public function getPageContent ( string $title, int $section = null ) : string {
45 45
 		$msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' );
46 46
 		$this->logger->debug( $msg );
47 47
 		$params = [
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		];
54 54
 
55 55
 		if ( $section !== null ) {
56
-			$params['rvsection'] = $section;
56
+			$params[ 'rvsection' ] = $section;
57 57
 		}
58 58
 
59 59
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			throw new MissingPageException( $title );
64 64
 		}
65 65
 
66
-		$mainSlot = $page->revisions[0]->slots->main;
66
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
67 67
 
68 68
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
69 69
 			throw new MissingSectionException( $title, $section );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param array $params
78 78
 	 * @throws EditException
79 79
 	 */
80
-	public function editPage( array $params ) {
80
+	public function editPage ( array $params ) {
81 81
 		$this->login();
82 82
 
83 83
 		$params = [
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		] + $params;
87 87
 
88 88
 		if ( Config::getInstance()->get( 'bot-edits' ) ) {
89
-			$params['bot'] = 1;
89
+			$params[ 'bot' ] = 1;
90 90
 		}
91 91
 
92 92
 		$res = RequestBase::newFromParams( $params )
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
108 108
 	 * @throws LoginException
109 109
 	 */
110
-	public function login() {
110
+	public function login () {
111 111
 		if ( self::$loggedIn ) {
112 112
 			return;
113 113
 		}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 		self::$loggedIn = true;
136 136
 		// Clear tokens cache
137
-		$this->tokens = [];
137
+		$this->tokens = [ ];
138 138
 		$this->logger->info( 'Login succeeded' );
139 139
 	}
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param string $type
145 145
 	 * @return string
146 146
 	 */
147
-	public function getToken( string $type ) : string {
147
+	public function getToken ( string $type ) : string {
148 148
 		if ( !isset( $this->tokens[ $type ] ) ) {
149 149
 			$params = [
150 150
 				'action' => 'query',
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string $title
168 168
 	 * @return int
169 169
 	 */
170
-	public function getPageCreationTS( string $title ) : int {
170
+	public function getPageCreationTS ( string $title ) : int {
171 171
 		$params = [
172 172
 			'action' => 'query',
173 173
 			'prop' => 'revisions',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
182 182
 		$data = $res->query->pages;
183
-		return strtotime( reset( $data )->revisions[0]->timestamp );
183
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
184 184
 	}
185 185
 
186 186
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param string $title
190 190
 	 * @param string $reason
191 191
 	 */
192
-	public function protectPage( string $title, string $reason ) {
192
+	public function protectPage ( string $title, string $reason ) {
193 193
 		$this->logger->info( "Protecting page $title" );
194 194
 		$this->login();
195 195
 
Please login to merge, or discard this patch.