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

TradeGood::getAll()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 13
nc 2
nop 0
dl 0
loc 17
rs 9.8333
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
class TradeGood {
6
7
	/** @var array<int, self> */
8
	private static array $CACHE_GOODS = [];
9
10
	public static function clearCache(): void {
11
		self::$CACHE_GOODS = [];
12
	}
13
14
	/**
15
	 * @return array<int, self>
16
	 */
17
	public static function getAll(): array {
18
		if (empty(self::$CACHE_GOODS)) {
19
			$db = Database::getInstance();
20
			$dbResult = $db->read('SELECT * FROM good');
21
			foreach ($dbResult->records() as $dbRecord) {
22
				$goodID = $dbRecord->getInt('good_id');
23
				self::$CACHE_GOODS[$goodID] = new self(
24
					id: $goodID,
25
					name: $dbRecord->getString('good_name'),
26
					maxPortAmount: $dbRecord->getInt('max_amount'),
27
					basePrice: $dbRecord->getInt('base_price'),
28
					class: $dbRecord->getInt('good_class'),
29
					alignRestriction: $dbRecord->getInt('align_restriction'),
30
				);
31
			}
32
		}
33
		return self::$CACHE_GOODS;
34
	}
35
36
	/**
37
	 * @return array<int>
38
	 */
39
	public static function getAllIDs(): array {
40
		return array_keys(self::getAll());
41
	}
42
43
	public static function get(int $goodID): self {
44
		return self::getAll()[$goodID];
45
	}
46
47
	public function __construct(
48
		public readonly int $id,
49
		public readonly string $name,
50
		public readonly int $maxPortAmount,
51
		public readonly int $basePrice,
52
		public readonly int $class,
53
		public readonly int $alignRestriction,
54
	) {}
55
56
	public function getImageHTML(): string {
57
		return '<img class="bottom" src="images/port/' . $this->id . '.png" width="13" height="16" title="' . $this->name . '" alt="' . $this->name . '" />';
58
	}
59
60
}
61