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 (#1494)
by Dan
10:59 queued 05:29
created

CombatLogViewer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 41
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A build() 0 27 3
1
<?php declare(strict_types=1);
2
3
namespace Smr\Pages\Player;
4
5
use AbstractSmrPlayer;
6
use Menu;
7
use Smr\Database;
8
use Smr\Page\PlayerPage;
9
use Smr\Page\ReusableTrait;
10
use Smr\Template;
11
12
class CombatLogViewer extends PlayerPage {
13
14
	use ReusableTrait;
15
16
	public string $file = 'combat_log_viewer.php';
17
18
	/**
19
	 * @param non-empty-array<int> $logIDs
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-array<int> at position 0 could not be parsed: Unknown type name 'non-empty-array' at position 0 in non-empty-array<int>.
Loading history...
20
	 */
21
	public function __construct(
22
		private readonly array $logIDs,
23
		private readonly int $currentLog = 0
24
	) {}
25
26
	public function build(AbstractSmrPlayer $player, Template $template): void {
27
		// Set properties for the current display page
28
		$display_id = $this->logIDs[$this->currentLog];
29
		$db = Database::getInstance();
30
		$dbResult = $db->read('SELECT timestamp,sector_id,result,type FROM combat_logs WHERE log_id=' . $db->escapeNumber($display_id) . ' LIMIT 1');
31
32
		$dbRecord = $dbResult->record();
33
		$template->assign('CombatLogSector', $dbRecord->getInt('sector_id'));
34
		$template->assign('CombatLogTimestamp', date($player->getAccount()->getDateTimeFormat(), $dbRecord->getInt('timestamp')));
35
		$results = $dbRecord->getObject('result', true);
36
		$template->assign('CombatResultsType', $dbRecord->getString('type'));
37
		$template->assign('CombatResults', $results);
38
39
		// Create a container for the next/previous log.
40
		// We initialize it with the current $var, then modify it to set
41
		// which log to view when we press the next/previous log buttons.
42
		if ($this->currentLog > 0) {
43
			$container = new self($this->logIDs, $this->currentLog - 1);
44
			$template->assign('PreviousLogHREF', $container->href());
45
		}
46
		if ($this->currentLog < count($this->logIDs) - 1) {
47
			$container = new self($this->logIDs, $this->currentLog + 1);
48
			$template->assign('NextLogHREF', $container->href());
49
		}
50
51
		$template->assign('PageTopic', 'Combat Logs');
52
		Menu::combatLog();
53
	}
54
55
}
56