Passed
Branch master (a4e902)
by Daimona
01:39
created

StartNew::runInternal()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
1
<?php declare( strict_types=1 );
2
3
namespace BotRiconferme\Task;
4
5
use BotRiconferme\Task\Subtask\CreatePages;
6
use BotRiconferme\Task\Subtask\UpdatesAround;
7
use BotRiconferme\Task\Subtask\UserNotice;
8
use BotRiconferme\TaskResult;
9
10
/**
11
 * Task for opening new procedures
12
 */
13
class StartNew extends Task {
14
	/**
15
	 * @inheritDoc
16
	 */
17
	public function runInternal() : int {
18
		$orderedList = [
19
			'update-list',
20
			'create-pages',
21
			'updates-around',
22
			'user-notice'
23
		];
24
25
		$res = new TaskResult( TaskResult::STATUS_OK );
26
		do {
27
			$res->merge( $this->runSubtask( current( $orderedList ) ) );
28
		} while ( $res->isOK() && next( $orderedList ) );
29
30
		return $res->getStatus();
31
	}
32
33
	/**
34
	 * @inheritDoc
35
	 */
36
	protected function getSubtasksMap() : array {
37
		return [
38
			'create-pages' => CreatePages::class,
39
			'update-list' => UpdateList::class,
40
			'updates-around' => UpdatesAround::class,
41
			'user-notice' => UserNotice::class,
42
		];
43
	}
44
}
45