@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -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 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -8,7 +8,7 @@ discard block |
||
| 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 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -9,39 +9,39 @@ discard block |
||
| 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 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param int $status One of the Task::STATUS_* constants |
| 18 | 18 | * @param string[] $errors |
| 19 | 19 | */ |
| 20 | - public function __construct( int $status, array $errors = [] ) { |
|
| 20 | + public function __construct(int $status, array $errors = []) { |
|
| 21 | 21 | $this->status = $status; |
| 22 | 22 | $this->errors = $errors; |
| 23 | 23 | } |
@@ -39,25 +39,25 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @param TaskResult $that |
| 41 | 41 | */ |
| 42 | - public function merge( TaskResult $that ) { |
|
| 42 | + public function merge(TaskResult $that) { |
|
| 43 | 43 | $this->status |= $that->status; |
| 44 | - $this->errors = array_merge( $this->errors, $that->errors ); |
|
| 44 | + $this->errors = array_merge($this->errors, $that->errors); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | 50 | public function __toString() { |
| 51 | - if ( $this->isOK() ) { |
|
| 51 | + if ($this->isOK()) { |
|
| 52 | 52 | $stat = 'OK'; |
| 53 | 53 | $errs = "\tNo errors."; |
| 54 | 54 | } else { |
| 55 | 55 | $stat = 'ERROR'; |
| 56 | 56 | $formattedErrs = []; |
| 57 | - foreach ( $this->errors as $err ) { |
|
| 57 | + foreach ($this->errors as $err) { |
|
| 58 | 58 | $formattedErrs[] = "\t - $err"; |
| 59 | 59 | } |
| 60 | - $errs = implode( "\n", $formattedErrs ); |
|
| 60 | + $errs = implode("\n", $formattedErrs); |
|
| 61 | 61 | } |
| 62 | 62 | return "=== RESULT ===\n - Status: $stat\n - Errors:\n$errs\n"; |
| 63 | 63 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Request; |
| 4 | 4 | |
@@ -9,25 +9,25 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | 11 | */ |
| 12 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 12 | + protected function reallyMakeRequest(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 | 19 | $url = self::$url; |
| 20 | - if ( $this->method === 'POST' ) { |
|
| 20 | + if ($this->method === 'POST') { |
|
| 21 | 21 | $context['http']['content'] = $params; |
| 22 | 22 | } else { |
| 23 | 23 | $url = "$url?$params"; |
| 24 | 24 | } |
| 25 | - $context = stream_context_create( $context ); |
|
| 26 | - $body = file_get_contents( $url, false, $context ); |
|
| 25 | + $context = stream_context_create($context); |
|
| 26 | + $body = file_get_contents($url, false, $context); |
|
| 27 | 27 | |
| 28 | - foreach ( $http_response_header as $header ) { |
|
| 29 | - $bits = explode( ':', $header, 2 ); |
|
| 30 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 28 | + foreach ($http_response_header as $header) { |
|
| 29 | + $bits = explode(':', $header, 2); |
|
| 30 | + if (trim($bits[0]) === 'Set-Cookie') { |
|
| 31 | 31 | $this->newCookies[] = $bits[1]; |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |