Passed
Push — master ( 35639c...18326f )
by Daimona
01:42
created
includes/Bot.php 1 patch
Spacing   +5 added lines, -5 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;
4 4
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 	const VERSION = 1.0;
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
18 18
 	/**
19 19
 	 * Entry point for the whole process
20 20
 	 */
21
-	public function run() {
21
+	public function run () {
22 22
 		$this->logger->info( 'Starting full process.' );
23 23
 		$manager = new TaskManager;
24 24
 		$res = $manager->run( TaskManager::MODE_COMPLETE );
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $task
37 37
 	 */
38
-	public function runTask( string $task ) {
38
+	public function runTask ( string $task ) {
39 39
 		$this->logger->info( "Starting single task $task." );
40 40
 		$manager = new TaskManager;
41 41
 		$res = $manager->run( TaskManager::MODE_TASK, $task );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @param string $subtask
54 54
 	 */
55
-	public function runSubtask( string $subtask ) {
55
+	public function runSubtask ( string $subtask ) {
56 56
 		$this->logger->info( "Starting single subtask $subtask." );
57 57
 		$manager = new TaskManager;
58 58
 		$res = $manager->run( TaskManager::MODE_SUBTASK, $subtask );
Please login to merge, or discard this patch.
includes/TaskManager.php 1 patch
Spacing   +9 added lines, -9 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;
4 4
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
48 48
 	 * @return TaskResult
49 49
 	 */
50
-	public function run( int $mode, string $name = null ) : TaskResult {
50
+	public function run ( int $mode, string $name = null ) : TaskResult {
51 51
 		$this->provider = new TaskDataProvider;
52 52
 
53 53
 		if ( $mode === self::MODE_COMPLETE ) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return TaskResult
66 66
 	 */
67
-	protected function runAllTasks() : TaskResult {
67
+	protected function runAllTasks () : TaskResult {
68 68
 		if ( self::getLastFullRunDate() === date( 'd/m/Y' ) ) {
69 69
 			// Really avoid executing twice the same day
70 70
 			return new TaskResult( TaskResult::STATUS_ERROR, [ 'A full run was already executed today.' ] );
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param string $name
96 96
 	 * @return TaskResult
97 97
 	 */
98
-	protected function runTask( string $name ) : TaskResult {
98
+	protected function runTask ( string $name ) : TaskResult {
99 99
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
100 100
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
101 101
 		}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param string $name
111 111
 	 * @return TaskResult
112 112
 	 */
113
-	protected function runSubtask( string $name ) : TaskResult {
113
+	protected function runSubtask ( string $name ) : TaskResult {
114 114
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
115 115
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
116 116
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return string|null d/m/Y or null if no last run registered
125 125
 	 * @fixme Is this even necessary?
126 126
 	 */
127
-	public static function getLastFullRunDate() : ?string {
127
+	public static function getLastFullRunDate () : ?string {
128 128
 		if ( file_exists( self::LOG_FILE ) ) {
129 129
 			return file_get_contents( self::LOG_FILE ) ?: null;
130 130
 		} else {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param string $class
139 139
 	 * @return Task
140 140
 	 */
141
-	private function getTaskInstance( string $class ) : Task {
141
+	private function getTaskInstance ( string $class ) : Task {
142 142
 		return new $class( $this->provider );
143 143
 	}
144 144
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 * @param string $class
149 149
 	 * @return Subtask
150 150
 	 */
151
-	private function getSubtaskInstance( string $class ) : Subtask {
151
+	private function getSubtaskInstance ( string $class ) : Subtask {
152 152
 		return new $class( $this->provider );
153 153
 	}
154 154
 
155
-	public static function setLastFullRunDate() {
155
+	public static function setLastFullRunDate () {
156 156
 		file_put_contents( self::LOG_FILE, date( 'd/m/Y' ) );
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +4 added lines, -4 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
  * Entry point for the bot, called by CLI
4 4
  */
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 /* URL (for debugging purpose) */
39 39
 $urlParam = getopt( '', [ 'force-url:' ] );
40
-$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php';
40
+$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php';
41 41
 
42 42
 define( 'DEFAULT_URL', $url );
43 43
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
 if ( count( $taskOpts ) === 2 ) {
89 89
 	throw new InvalidArgumentException( 'Cannot specify both task and subtask.' );
90
-} elseif ( isset( $taskOpts['task'] ) ) {
90
+} elseif ( isset( $taskOpts[ 'task' ] ) ) {
91 91
 	$bot->runTask( $taskOpts[ 'task' ] );
92
-} elseif ( isset( $taskOpts['subtask'] ) ) {
92
+} elseif ( isset( $taskOpts[ 'subtask' ] ) ) {
93 93
 	$bot->runSubtask( $taskOpts[ 'subtask' ] );
94 94
 } else {
95 95
 	$bot->run();
Please login to merge, or discard this patch.