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

Passed
Pull Request — master (#893)
by Dan
04:05
created

buildShipStats()   B

Complexity

Conditions 8
Paths 96

Size

Total Lines 31
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 26
nc 96
nop 1
dl 0
loc 31
rs 8.4444
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
try {
3
	require_once('config.inc');
4
5
	$template = new Template();
6
7
	$gameType = ''; // no game type here
8
	foreach (SmrShip::getAllBaseShips($gameType) as $ship) {
9
		$shipArray[] = buildShipStats($ship);
10
	}
11
	$template->assign('shipArray', $shipArray);
12
13
	$speeds = array_unique(array_column($shipArray, 'speed'));
14
	rsort($speeds);
15
	$template->assign('Speeds', $speeds);
16
17
	$hardpoints = array_unique(array_column($shipArray, 'hardpoint'));
18
	rsort($hardpoints);
19
	$template->assign('Hardpoints', $hardpoints);
20
21
	$booleanFields = ['Scanner', 'Cloak', 'Illusion', 'Jump', 'Scrambler'];
22
	$template->assign('BooleanFields', $booleanFields);
23
24
	$template->display('ship_list.php');
25
} catch (Throwable $e) {
26
	handleException($e);
27
}
28
29
function buildShipStats($ship) {
30
	//we want to put them all in an array so we dont have to have 15 td rows
31
	if ($ship['AlignRestriction'] == BUYER_RESTRICTION_GOOD) {
32
		$restriction = '<span class="dgreen">Good</span>';
33
	} elseif ($ship['AlignRestriction'] == BUYER_RESTRICTION_EVIL) {
34
		$restriction = '<span class="red">Evil</span>';
35
	} else {
36
		$restriction = '';
37
	}
38
	// Array key is the td class (sort key), and array value is the data value
39
	$stat = [
40
		'name' => $ship['Name'],
41
		'race race' . $ship['RaceID'] => Globals::getRaceName($ship['RaceID']),
42
		'class_' => Globals::getShipClass($ship['ShipClassID']),
43
		'cost' => number_format($ship['Cost']),
44
		'speed' => $ship['Speed'],
45
		'hardpoint' => $ship['Hardpoint'],
46
		'restriction' => $restriction,
47
		'shields' => $ship['MaxHardware'][HARDWARE_SHIELDS],
48
		'armour' => $ship['MaxHardware'][HARDWARE_ARMOUR],
49
		'cargo' => $ship['MaxHardware'][HARDWARE_CARGO],
50
		'cds' => $ship['MaxHardware'][HARDWARE_COMBAT],
51
		'scouts' => $ship['MaxHardware'][HARDWARE_SCOUT],
52
		'mines' => $ship['MaxHardware'][HARDWARE_MINE],
53
		'scanner' => $ship['MaxHardware'][HARDWARE_SCANNER] == 1 ? 'Yes' : '',
54
		'cloak' => $ship['MaxHardware'][HARDWARE_CLOAK] == 1 ? 'Yes' : '',
55
		'illusion' => $ship['MaxHardware'][HARDWARE_ILLUSION] == 1 ? 'Yes' : '',
56
		'jump' => $ship['MaxHardware'][HARDWARE_JUMP] == 1 ? 'Yes' : '',
57
		'scrambler' => $ship['MaxHardware'][HARDWARE_DCS] == 1 ? 'Yes' : '',
58
	];
59
	return $stat;
60
}
61