@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | private $controller; |
| 17 | 17 | |
| 18 | 18 | public function __construct() { |
| 19 | - $this->setLogger( new Logger ); |
|
| 20 | - $this->setConfig( Config::getInstance() ); |
|
| 21 | - $this->setController( new WikiController ); |
|
| 19 | + $this->setLogger(new Logger); |
|
| 20 | + $this->setConfig(Config::getInstance()); |
|
| 21 | + $this->setController(new WikiController); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @inheritDoc |
| 33 | 33 | */ |
| 34 | - public function setLogger( LoggerInterface $logger ) { |
|
| 34 | + public function setLogger(LoggerInterface $logger) { |
|
| 35 | 35 | $this->logger = $logger; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @param Config $cfg |
| 47 | 47 | */ |
| 48 | - protected function setConfig( Config $cfg ) { |
|
| 48 | + protected function setConfig(Config $cfg) { |
|
| 49 | 49 | $this->config = $cfg; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | /** |
| 60 | 60 | * @param WikiController $controller |
| 61 | 61 | */ |
| 62 | - protected function setController( WikiController $controller ) { |
|
| 62 | + protected function setController(WikiController $controller) { |
|
| 63 | 63 | $this->controller = $controller; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -13,20 +13,20 @@ discard block |
||
| 13 | 13 | * @return array[] |
| 14 | 14 | */ |
| 15 | 15 | public function getUsersToProcess() : array { |
| 16 | - if ( $this->users === null ) { |
|
| 17 | - $this->getLogger()->debug( 'Retrieving users list' ); |
|
| 18 | - $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
|
| 19 | - $listUsers = json_decode( $content, true ); |
|
| 16 | + if ($this->users === null) { |
|
| 17 | + $this->getLogger()->debug('Retrieving users list'); |
|
| 18 | + $content = $this->getController()->getPageContent($this->getConfig()->get('list-title')); |
|
| 19 | + $listUsers = json_decode($content, true); |
|
| 20 | 20 | |
| 21 | 21 | $this->users = []; |
| 22 | - foreach ( $listUsers as $user => $groups ) { |
|
| 23 | - $timestamp = $this->getValidTimestamp( $groups ); |
|
| 22 | + foreach ($listUsers as $user => $groups) { |
|
| 23 | + $timestamp = $this->getValidTimestamp($groups); |
|
| 24 | 24 | |
| 25 | - if ( date( 'd/m', $timestamp ) === date( 'd/m' ) && |
|
| 25 | + if (date('d/m', $timestamp) === date('d/m') && |
|
| 26 | 26 | // Don't trigger if the date is actually today |
| 27 | - date( 'd/m/Y', $timestamp ) !== date( 'd/m/Y' ) |
|
| 27 | + date('d/m/Y', $timestamp) !== date('d/m/Y') |
|
| 28 | 28 | ) { |
| 29 | - $this->users[ $user ] = $groups; |
|
| 29 | + $this->users[$user] = $groups; |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -40,17 +40,15 @@ discard block |
||
| 40 | 40 | * @param array $groups |
| 41 | 41 | * @return int |
| 42 | 42 | */ |
| 43 | - private function getValidTimestamp( array $groups ) : int { |
|
| 44 | - $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 45 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : |
|
| 46 | - 0; |
|
| 47 | - $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 48 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : |
|
| 49 | - 0; |
|
| 43 | + private function getValidTimestamp(array $groups) : int { |
|
| 44 | + $checkuser = isset($groups['checkuser']) ? |
|
| 45 | + \DateTime::createFromFormat('d/m/Y', $groups['checkuser'])->getTimestamp() : 0; |
|
| 46 | + $bureaucrat = isset($groups['bureaucrat']) ? |
|
| 47 | + \DateTime::createFromFormat('d/m/Y', $groups['bureaucrat'])->getTimestamp() : 0; |
|
| 50 | 48 | |
| 51 | - $timestamp = max( $bureaucrat, $checkuser ); |
|
| 52 | - if ( $timestamp === 0 ) { |
|
| 53 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 49 | + $timestamp = max($bureaucrat, $checkuser); |
|
| 50 | + if ($timestamp === 0) { |
|
| 51 | + $timestamp = \DateTime::createFromFormat('d/m/Y', $groups['sysop'])->getTimestamp(); |
|
| 54 | 52 | } |
| 55 | 53 | return $timestamp; |
| 56 | 54 | } |
@@ -58,8 +56,8 @@ discard block |
||
| 58 | 56 | /** |
| 59 | 57 | * @param string $name |
| 60 | 58 | */ |
| 61 | - public function removeUser( string $name ) { |
|
| 62 | - unset( $this->users[ $name ] ); |
|
| 59 | + public function removeUser(string $name) { |
|
| 60 | + unset($this->users[$name]); |
|
| 63 | 61 | } |
| 64 | 62 | |
| 65 | 63 | /** |
@@ -72,7 +70,7 @@ discard block |
||
| 72 | 70 | /** |
| 73 | 71 | * @param string $title |
| 74 | 72 | */ |
| 75 | - public function addCreatedPages( string $title ) { |
|
| 73 | + public function addCreatedPages(string $title) { |
|
| 76 | 74 | $this->createdPages[] = $title; |
| 77 | 75 | } |
| 78 | 76 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | * @param array $params |
| 33 | 33 | * @param bool $isPOST |
| 34 | 34 | */ |
| 35 | - protected function __construct( array $params, bool $isPOST = false ) { |
|
| 36 | - $this->params = [ 'format' => 'json' ] + $params; |
|
| 35 | + protected function __construct(array $params, bool $isPOST = false) { |
|
| 36 | + $this->params = ['format' => 'json'] + $params; |
|
| 37 | 37 | $this->method = $isPOST ? 'POST' : 'GET'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | * @param bool $isPOST |
| 45 | 45 | * @return self |
| 46 | 46 | */ |
| 47 | - public static function newFromParams( array $params, bool $isPOST = false ) : self { |
|
| 48 | - if ( extension_loaded( 'curl' ) ) { |
|
| 49 | - $ret = new CurlRequest( $params, $isPOST ); |
|
| 47 | + public static function newFromParams(array $params, bool $isPOST = false) : self { |
|
| 48 | + if (extension_loaded('curl')) { |
|
| 49 | + $ret = new CurlRequest($params, $isPOST); |
|
| 50 | 50 | } else { |
| 51 | - $ret = new NativeRequest( $params, $isPOST ); |
|
| 51 | + $ret = new NativeRequest($params, $isPOST); |
|
| 52 | 52 | } |
| 53 | 53 | return $ret; |
| 54 | 54 | } |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | $curParams = $this->params; |
| 63 | 63 | $sets = []; |
| 64 | 64 | do { |
| 65 | - $res = $this->makeRequestInternal( $curParams ); |
|
| 65 | + $res = $this->makeRequestInternal($curParams); |
|
| 66 | 66 | |
| 67 | - $this->handleErrorAndWarnings( $res ); |
|
| 67 | + $this->handleErrorAndWarnings($res); |
|
| 68 | 68 | $sets[] = $res; |
| 69 | 69 | |
| 70 | 70 | $finished = true; |
| 71 | - if ( isset( $res->continue ) ) { |
|
| 72 | - $curParams = array_merge( $curParams, get_object_vars( $res->continue ) ); |
|
| 71 | + if (isset($res->continue)) { |
|
| 72 | + $curParams = array_merge($curParams, get_object_vars($res->continue)); |
|
| 73 | 73 | $finished = false; |
| 74 | 74 | } |
| 75 | - } while ( !$finished ); |
|
| 75 | + } while (!$finished); |
|
| 76 | 76 | |
| 77 | - return $this->mergeSets( $sets ); |
|
| 77 | + return $this->mergeSets($sets); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | * @param \stdClass[] $sets |
| 84 | 84 | * @return array |
| 85 | 85 | */ |
| 86 | - private function mergeSets( array $sets ) : array { |
|
| 87 | - $sets = $this->objectToArray( $sets ); |
|
| 86 | + private function mergeSets(array $sets) : array { |
|
| 87 | + $sets = $this->objectToArray($sets); |
|
| 88 | 88 | // Use the first set as template |
| 89 | - $ret = array_shift( $sets ); |
|
| 89 | + $ret = array_shift($sets); |
|
| 90 | 90 | $act = $this->params['action']; |
| 91 | 91 | |
| 92 | - foreach ( $sets as $set ) { |
|
| 92 | + foreach ($sets as $set) { |
|
| 93 | 93 | $ret[$act] = array_merge_recursive( |
| 94 | - $this->objectToArray( $ret[$act] ), |
|
| 95 | - $this->objectToArray( $set[$act] ) |
|
| 94 | + $this->objectToArray($ret[$act]), |
|
| 95 | + $this->objectToArray($set[$act]) |
|
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | return $ret; |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * @param \stdClass|array $objOrArray |
| 106 | 106 | * @return array |
| 107 | 107 | */ |
| 108 | - private function objectToArray( $objOrArray ) : array { |
|
| 108 | + private function objectToArray($objOrArray) : array { |
|
| 109 | 109 | $array = []; |
| 110 | - if ( is_object( $objOrArray ) ) { |
|
| 111 | - $objOrArray = get_object_vars( $objOrArray ); |
|
| 110 | + if (is_object($objOrArray)) { |
|
| 111 | + $objOrArray = get_object_vars($objOrArray); |
|
| 112 | 112 | } |
| 113 | - foreach ( $objOrArray as $key => $value ) { |
|
| 114 | - if ( is_object( $value ) || is_array( $value ) ) { |
|
| 115 | - $value = $this->objectToArray( $value ); |
|
| 113 | + foreach ($objOrArray as $key => $value) { |
|
| 114 | + if (is_object($value) || is_array($value)) { |
|
| 115 | + $value = $this->objectToArray($value); |
|
| 116 | 116 | } |
| 117 | 117 | $array[$key] = $value; |
| 118 | 118 | } |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | * @param array $params |
| 126 | 126 | * @return \stdClass |
| 127 | 127 | */ |
| 128 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 129 | - $url = Config::getInstance()->get( 'url' ); |
|
| 128 | + private function makeRequestInternal(array $params) : \stdClass { |
|
| 129 | + $url = Config::getInstance()->get('url'); |
|
| 130 | 130 | |
| 131 | - if ( $this->method === 'POST' ) { |
|
| 131 | + if ($this->method === 'POST') { |
|
| 132 | 132 | $params['maxlag'] = self::MAXLAG; |
| 133 | 133 | } |
| 134 | - $params = http_build_query( $params ); |
|
| 134 | + $params = http_build_query($params); |
|
| 135 | 135 | |
| 136 | - $body = $this->reallyMakeRequest( $url, $params ); |
|
| 136 | + $body = $this->reallyMakeRequest($url, $params); |
|
| 137 | 137 | |
| 138 | - $this->setCookies( $this->newCookies ); |
|
| 139 | - return json_decode( $body ); |
|
| 138 | + $this->setCookies($this->newCookies); |
|
| 139 | + return json_decode($body); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -146,16 +146,16 @@ discard block |
||
| 146 | 146 | * @param string $params |
| 147 | 147 | * @return string |
| 148 | 148 | */ |
| 149 | - abstract protected function reallyMakeRequest( string $url, string $params ) : string; |
|
| 149 | + abstract protected function reallyMakeRequest(string $url, string $params) : string; |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * @param array $cookies |
| 153 | 153 | */ |
| 154 | - protected function setCookies( array $cookies ) { |
|
| 155 | - foreach ( $cookies as $cookie ) { |
|
| 156 | - $bits = explode( ';', $cookie ); |
|
| 157 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
| 158 | - self::$cookiesToSet[ $name ] = $value; |
|
| 154 | + protected function setCookies(array $cookies) { |
|
| 155 | + foreach ($cookies as $cookie) { |
|
| 156 | + $bits = explode(';', $cookie); |
|
| 157 | + list($name, $value) = explode('=', $bits[0]); |
|
| 158 | + self::$cookiesToSet[$name] = $value; |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | * @param \stdClass $res |
| 164 | 164 | * @throws APIRequestException |
| 165 | 165 | */ |
| 166 | - protected function handleErrorAndWarnings( $res ) { |
|
| 167 | - if ( isset( $res->error ) ) { |
|
| 168 | - switch ( $res->error->code ) { |
|
| 166 | + protected function handleErrorAndWarnings($res) { |
|
| 167 | + if (isset($res->error)) { |
|
| 168 | + switch ($res->error->code) { |
|
| 169 | 169 | case 'missingtitle': |
| 170 | 170 | $ex = new MissingPageException; |
| 171 | 171 | break; |
@@ -173,13 +173,13 @@ discard block |
||
| 173 | 173 | $ex = new ProtectedPageException; |
| 174 | 174 | break; |
| 175 | 175 | default: |
| 176 | - $ex = new APIRequestException( $res->error->code . ' - ' . $res->error->info ); |
|
| 176 | + $ex = new APIRequestException($res->error->code . ' - ' . $res->error->info); |
|
| 177 | 177 | } |
| 178 | 178 | throw $ex; |
| 179 | - } elseif ( isset( $res->warnings ) ) { |
|
| 180 | - $act = $this->params[ 'action' ]; |
|
| 179 | + } elseif (isset($res->warnings)) { |
|
| 180 | + $act = $this->params['action']; |
|
| 181 | 181 | $warning = $res->warnings->$act; |
| 182 | - throw new APIRequestException( reset( $warning ) ); |
|
| 182 | + throw new APIRequestException(reset($warning)); |
|
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | protected function getHeaders() :array { |
| 190 | 190 | $ret = self::HEADERS; |
| 191 | - if ( self::$cookiesToSet ) { |
|
| 191 | + if (self::$cookiesToSet) { |
|
| 192 | 192 | $cookies = []; |
| 193 | - foreach ( self::$cookiesToSet as $cname => $cval ) { |
|
| 194 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 193 | + foreach (self::$cookiesToSet as $cname => $cval) { |
|
| 194 | + $cookies[] = trim("$cname=$cval"); |
|
| 195 | 195 | } |
| 196 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 196 | + $ret[] = 'Cookie: ' . implode('; ', $cookies); |
|
| 197 | 197 | } |
| 198 | 198 | return $ret; |
| 199 | 199 | } |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | * @param array $headers |
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | - protected function buildHeadersString( array $headers ) : string { |
|
| 205 | + protected function buildHeadersString(array $headers) : string { |
|
| 206 | 206 | $ret = ''; |
| 207 | - foreach ( $headers as $header ) { |
|
| 207 | + foreach ($headers as $header) { |
|
| 208 | 208 | $ret .= "$header\r\n"; |
| 209 | 209 | } |
| 210 | 210 | return $ret; |
@@ -11,31 +11,31 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - protected function reallyMakeRequest( string $url, string $params ) : string { |
|
| 14 | + protected function reallyMakeRequest(string $url, string $params) : string { |
|
| 15 | 15 | $curl = curl_init(); |
| 16 | - curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); |
|
| 17 | - curl_setopt( $curl, CURLOPT_HEADER, true ); |
|
| 18 | - curl_setopt( $curl, CURLOPT_HEADERFUNCTION, [ $this, 'headersHandler' ] ); |
|
| 19 | - curl_setopt( $curl, CURLOPT_HTTPHEADER, $this->getHeaders() ); |
|
| 20 | - |
|
| 21 | - if ( $this->method === 'POST' ) { |
|
| 22 | - curl_setopt( $curl, CURLOPT_URL, $url ); |
|
| 23 | - curl_setopt( $curl, CURLOPT_POST, true ); |
|
| 24 | - curl_setopt( $curl, CURLOPT_POSTFIELDS, $params ); |
|
| 16 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 17 | + curl_setopt($curl, CURLOPT_HEADER, true); |
|
| 18 | + curl_setopt($curl, CURLOPT_HEADERFUNCTION, [$this, 'headersHandler']); |
|
| 19 | + curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeaders()); |
|
| 20 | + |
|
| 21 | + if ($this->method === 'POST') { |
|
| 22 | + curl_setopt($curl, CURLOPT_URL, $url); |
|
| 23 | + curl_setopt($curl, CURLOPT_POST, true); |
|
| 24 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
| 25 | 25 | } else { |
| 26 | - curl_setopt( $curl, CURLOPT_URL, "$url?$params" ); |
|
| 26 | + curl_setopt($curl, CURLOPT_URL, "$url?$params"); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $result = curl_exec( $curl ); |
|
| 29 | + $result = curl_exec($curl); |
|
| 30 | 30 | |
| 31 | - if ( $result === false ) { |
|
| 32 | - throw new APIRequestException( curl_error( $curl ) ); |
|
| 31 | + if ($result === false) { |
|
| 32 | + throw new APIRequestException(curl_error($curl)); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Extract response body |
| 36 | - $headerSize = curl_getinfo( $curl, CURLINFO_HEADER_SIZE ); |
|
| 37 | - $body = substr( $result, $headerSize ); |
|
| 38 | - curl_close( $curl ); |
|
| 36 | + $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); |
|
| 37 | + $body = substr($result, $headerSize); |
|
| 38 | + curl_close($curl); |
|
| 39 | 39 | |
| 40 | 40 | return $body; |
| 41 | 41 | } |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | * @return int |
| 49 | 49 | * @internal Only used as CB for cURL |
| 50 | 50 | */ |
| 51 | - public function headersHandler( $ch, string $header ) : int { |
|
| 52 | - $bits = explode( ':', $header, 2 ); |
|
| 53 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 51 | + public function headersHandler($ch, string $header) : int { |
|
| 52 | + $bits = explode(':', $header, 2); |
|
| 53 | + if (trim($bits[0]) === 'Set-Cookie') { |
|
| 54 | 54 | $this->newCookies[] = $bits[1]; |
| 55 | 55 | } |
| 56 | 56 | // @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string? |
| 57 | - return strlen( $header ); |
|
| 57 | + return strlen($header); |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -9,24 +9,24 @@ |
||
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | 11 | */ |
| 12 | - protected function reallyMakeRequest( string $url, string $params ) : string { |
|
| 12 | + protected function reallyMakeRequest(string $url, string $params) : string { |
|
| 13 | 13 | $context = [ |
| 14 | 14 | 'http' => [ |
| 15 | 15 | 'method' => $this->method, |
| 16 | - 'header' => $this->buildHeadersString( $this->getHeaders() ) |
|
| 16 | + 'header' => $this->buildHeadersString($this->getHeaders()) |
|
| 17 | 17 | ] |
| 18 | 18 | ]; |
| 19 | - if ( $this->method === 'POST' ) { |
|
| 19 | + if ($this->method === 'POST') { |
|
| 20 | 20 | $context['http']['content'] = $params; |
| 21 | 21 | } else { |
| 22 | 22 | $url = "$url?$params"; |
| 23 | 23 | } |
| 24 | - $context = stream_context_create( $context ); |
|
| 25 | - $body = file_get_contents( $url, false, $context ); |
|
| 24 | + $context = stream_context_create($context); |
|
| 25 | + $body = file_get_contents($url, false, $context); |
|
| 26 | 26 | |
| 27 | - foreach ( $http_response_header as $header ) { |
|
| 28 | - $bits = explode( ':', $header, 2 ); |
|
| 29 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 27 | + foreach ($http_response_header as $header) { |
|
| 28 | + $bits = explode(':', $header, 2); |
|
| 29 | + if (trim($bits[0]) === 'Set-Cookie') { |
|
| 30 | 30 | $this->newCookies[] = $bits[1]; |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * @param string|null $title |
| 8 | 8 | */ |
| 9 | - public function __construct( string $title = null ) { |
|
| 10 | - if ( $title ) { |
|
| 11 | - parent::__construct( "The specified page doesn't exist: $title" ); |
|
| 9 | + public function __construct(string $title = null) { |
|
| 10 | + if ($title) { |
|
| 11 | + parent::__construct("The specified page doesn't exist: $title"); |
|
| 12 | 12 | } else { |
| 13 | 13 | parent::__construct(); |
| 14 | 14 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * @param string|null $title |
| 8 | 8 | */ |
| 9 | - public function __construct( string $title = null ) { |
|
| 10 | - if ( $title ) { |
|
| 11 | - parent::__construct( "The specified page is protected: $title" ); |
|
| 9 | + public function __construct(string $title = null) { |
|
| 10 | + if ($title) { |
|
| 11 | + parent::__construct("The specified page is protected: $title"); |
|
| 12 | 12 | } else { |
| 13 | 13 | parent::__construct(); |
| 14 | 14 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | /** |
| 9 | 9 | * @inheritDoc |
| 10 | 10 | */ |
| 11 | - public function log( $level, $message, array $context = [] ) { |
|
| 12 | - error_log( "$level - $message" ); |
|
| 11 | + public function log($level, $message, array $context = []) { |
|
| 12 | + error_log("$level - $message"); |
|
| 13 | 13 | } |
| 14 | 14 | } |
@@ -9,39 +9,39 @@ |
||
| 9 | 9 | * @inheritDoc |
| 10 | 10 | */ |
| 11 | 11 | public function run() : TaskResult { |
| 12 | - $this->getLogger()->info( 'Starting task UserNotice' ); |
|
| 12 | + $this->getLogger()->info('Starting task UserNotice'); |
|
| 13 | 13 | |
| 14 | 14 | $ricNums = []; |
| 15 | - foreach ( $this->getDataProvider()->getCreatedPages() as $page ) { |
|
| 16 | - $bits = explode( '/', $page ); |
|
| 17 | - $num = intval( array_pop( $bits ) ); |
|
| 18 | - $ricNums[ array_pop( $bits ) ] = $num; |
|
| 15 | + foreach ($this->getDataProvider()->getCreatedPages() as $page) { |
|
| 16 | + $bits = explode('/', $page); |
|
| 17 | + $num = intval(array_pop($bits)); |
|
| 18 | + $ricNums[array_pop($bits)] = $num; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - foreach ( $this->getDataProvider()->getUsersToProcess() as $user => $_ ) { |
|
| 22 | - $this->addMsg( $user, $ricNums[ $user ] ); |
|
| 21 | + foreach ($this->getDataProvider()->getUsersToProcess() as $user => $_) { |
|
| 22 | + $this->addMsg($user, $ricNums[$user]); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - $this->getLogger()->info( 'Task UserNotice completed successfully' ); |
|
| 26 | - return new TaskResult( self::STATUS_OK ); |
|
| 25 | + $this->getLogger()->info('Task UserNotice completed successfully'); |
|
| 26 | + return new TaskResult(self::STATUS_OK); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @param string $user |
| 31 | 31 | * @param int $ricNum |
| 32 | 32 | */ |
| 33 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 34 | - $this->getLogger()->info( "Leaving msg to $user" ); |
|
| 35 | - $msg = str_replace( '$num', "$ricNum", $this->getConfig()->get( 'user-notice-msg' ) ); |
|
| 33 | + protected function addMsg(string $user, int $ricNum) { |
|
| 34 | + $this->getLogger()->info("Leaving msg to $user"); |
|
| 35 | + $msg = str_replace('$num', "$ricNum", $this->getConfig()->get('user-notice-msg')); |
|
| 36 | 36 | |
| 37 | 37 | $params = [ |
| 38 | 38 | 'title' => "User talk:$user", |
| 39 | 39 | 'section' => 'new', |
| 40 | 40 | 'text' => $msg, |
| 41 | - 'sectiontitle' => $this->getConfig()->get( 'user-notice-title' ), |
|
| 42 | - 'summary' => $this->getConfig()->get( 'user-notice-summary' ) |
|
| 41 | + 'sectiontitle' => $this->getConfig()->get('user-notice-title'), |
|
| 42 | + 'summary' => $this->getConfig()->get('user-notice-summary') |
|
| 43 | 43 | ]; |
| 44 | 44 | |
| 45 | - $this->getController()->editPage( $params ); |
|
| 45 | + $this->getController()->editPage($params); |
|
| 46 | 46 | } |
| 47 | 47 | } |