@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param array $params |
| 54 | 54 | */ |
| 55 | - public function edit( array $params ) { |
|
| 55 | + public function edit ( array $params ) { |
|
| 56 | 56 | $params = [ |
| 57 | 57 | 'title' => $this->getTitle() |
| 58 | 58 | ] + $params; |
| 59 | 59 | |
| 60 | 60 | $this->controller->editPage( $params ); |
| 61 | - if ( isset( $params['text'] ) ) { |
|
| 62 | - $this->content = $params['text']; |
|
| 63 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 64 | - $this->content .= $params['appendtext']; |
|
| 61 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 62 | + $this->content = $params[ 'text' ]; |
|
| 63 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 64 | + $this->content .= $params[ 'appendtext' ]; |
|
| 65 | 65 | } else { |
| 66 | 66 | // Clear the cache anyway |
| 67 | 67 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - public function exists() : bool { |
|
| 77 | + public function exists () : bool { |
|
| 78 | 78 | $res = RequestBase::newFromParams( [ |
| 79 | 79 | 'action' => 'query', |
| 80 | 80 | 'titles' => $this->getTitle() |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string $regex |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function matches( string $regex ) : bool { |
|
| 92 | + public function matches ( string $regex ) : bool { |
|
| 93 | 93 | return (bool)preg_match( $regex, $this->getContent() ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @return string[] |
| 102 | 102 | * @throws \Exception |
| 103 | 103 | */ |
| 104 | - public function getMatch( string $regex ) : array { |
|
| 105 | - $ret = []; |
|
| 104 | + public function getMatch ( string $regex ) : array { |
|
| 105 | + $ret = [ ]; |
|
| 106 | 106 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 107 | 107 | throw new \Exception( 'The content does not match the given regex' ); |
| 108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @inheritDoc |
| 116 | 116 | */ |
| 117 | - public function getRegex() : string { |
|
| 117 | + public function getRegex () : string { |
|
| 118 | 118 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string |
| 125 | 125 | */ |
| 126 | - public function __toString() { |
|
| 126 | + public function __toString () { |
|
| 127 | 127 | return $this->getTitle(); |
| 128 | 128 | } |
| 129 | 129 | } |