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
Pull Request — main (#1508)
by Dan
04:48
created

TraderStatus   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 47
dl 0
loc 73
rs 10
c 1
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B build() 0 67 7
1
<?php declare(strict_types=1);
2
3
namespace Smr\Pages\Player;
4
5
use AbstractSmrPlayer;
6
use Exception;
7
use Menu;
8
use Smr\Database;
9
use Smr\HardwareType;
10
use Smr\Page\PlayerPage;
11
use Smr\Page\ReusableTrait;
12
use Smr\Template;
13
14
class TraderStatus extends PlayerPage {
15
16
	use ReusableTrait;
17
18
	public string $file = 'trader_status.php';
19
20
	public function build(AbstractSmrPlayer $player, Template $template): void {
21
		$template->assign('PageTopic', 'Trader Status');
22
23
		Menu::trader();
24
25
		if ($player->hasNewbieTurns()) {
26
			$container = new NewbieLeave();
27
			$template->assign('LeaveNewbieHREF', $container->href());
28
		}
29
30
		$container = new TraderRelations();
31
		$template->assign('RelationsHREF', $container->href());
32
33
		$container = new TraderSavings();
34
		$template->assign('SavingsHREF', $container->href());
35
36
		// Bounties
37
		$container = new TraderBounties();
38
		$template->assign('BountiesHREF', $container->href());
39
40
		$template->assign('BountiesClaimable', count($player->getClaimableBounties()));
41
42
		// Ship
43
		$container = new HardwareConfigure();
44
		$template->assign('HardwareHREF', $container->href());
45
46
		$shipType = $player->getShip()->getType();
47
		$hardwareChecks = [
48
			HARDWARE_SCANNER => $shipType->canHaveScanner(),
49
			HARDWARE_ILLUSION => $shipType->canHaveIllusion(),
50
			HARDWARE_CLOAK => $shipType->canHaveCloak(),
51
			HARDWARE_JUMP => $shipType->canHaveJump(),
52
			HARDWARE_DCS => $shipType->canHaveDCS(),
53
		];
54
		$hardware = [];
55
		foreach ($hardwareChecks as $hardwareTypeID => $shipTypeCanHave) {
56
			if ($shipTypeCanHave) {
57
				$hardware[] = HardwareType::get($hardwareTypeID)->name;
58
			}
59
		}
60
		if (empty($hardware)) {
61
			$hardware[] = 'none';
62
		}
63
		$template->assign('Hardware', $hardware);
64
65
		$template->assign('NextLevel', $player->getLevel()->next());
66
67
		$container = new UserRankingView();
68
		$template->assign('UserRankingsHREF', $container->href());
69
70
		$container = new TraderNoteDeleteProcessor();
71
		$template->assign('NoteDeleteHREF', $container->href());
72
73
		$notes = [];
74
		$db = Database::getInstance();
75
		$dbResult = $db->read('SELECT * FROM player_has_notes WHERE ' . $player->getSQL() . ' ORDER BY note_id DESC');
76
		foreach ($dbResult->records() as $dbRecord) {
77
			$note = gzuncompress($dbRecord->getString('note'));
78
			if ($note === false) {
79
				throw new Exception('Failed to gzuncompress note!');
80
			}
81
			$notes[$dbRecord->getInt('note_id')] = $note;
82
		}
83
		$template->assign('Notes', $notes);
84
85
		$container = new TraderNoteAddProcessor();
86
		$template->assign('NoteAddHREF', $container->href());
87
	}
88
89
}
90