Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Push — dependabot/composer/phpunit/ph... ( 7173cc...f8df30 )
by
unknown
12:14 queued 06:41
created

shared_channel_msg_op_list()   B

Complexity

Conditions 8
Paths 25

Size

Total Lines 44
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 27
nc 25
nop 1
dl 0
loc 44
rs 8.4444
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
function shared_channel_msg_op_list(SmrPlayer $player): array {
4
	// get the op info from db
5
	$db = Smr\Database::getInstance();
6
	$dbResult = $db->read('SELECT 1
7
				FROM alliance_has_op
8
				WHERE alliance_id = ' . $db->escapeNumber($player->getAllianceID()) . '
9
					AND game_id = ' . $db->escapeNumber($player->getGameID()));
10
	if (!$dbResult->hasRecord()) {
11
		return ['Your leader has not scheduled an op.'];
12
	}
13
14
	$responses = [
15
		'YES' => [],
16
		'NO' => [],
17
		'MAYBE' => [],
18
	];
19
	$dbResult = $db->read('SELECT account_id, response
20
				FROM alliance_has_op_response
21
				WHERE alliance_id = ' . $db->escapeNumber($player->getAllianceID()) . '
22
					AND game_id = ' . $db->escapeNumber($player->getGameID()));
23
	foreach ($dbResult->records() as $dbRecord) {
24
		$respondingPlayer = SmrPlayer::getPlayer($dbRecord->getInt('account_id'), $player->getGameID(), true);
25
		// check that the player is still in this alliance
26
		if (!$player->sameAlliance($respondingPlayer)) {
27
			continue;
28
		}
29
		$responses[$dbRecord->getField('response')][] = $respondingPlayer;
30
	}
31
32
	$results = [];
33
	foreach ($responses as $response => $responders) {
34
		if (count($responders) > 0) {
35
			$results[] = $response . ' (' . count($responders) . '):';
36
			foreach ($responders as $responder) {
37
				$results[] = ' * ' . $responder->getPlayerName();
38
			}
39
		}
40
	}
41
42
	if (!$results) {
43
		return ['No one has responded to the upcoming op.'];
44
	}
45
46
	return $results;
47
}
48