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

HardwareType::getAll()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
nc 2
nop 0
dl 0
loc 14
rs 9.9332
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
class HardwareType {
6
7
	/** @var array<int, self> */
8
	private static array $CACHE_HARDWARE_TYPES = [];
9
10
	public static function clearCache(): void {
11
		self::$CACHE_HARDWARE_TYPES = [];
12
	}
13
14
	/**
15
	 * @return array<int, self>
16
	 */
17
	public static function getAll(): array {
18
		if (empty(self::$CACHE_HARDWARE_TYPES)) {
19
			$db = Database::getInstance();
20
			$dbResult = $db->read('SELECT * FROM hardware_type');
21
			foreach ($dbResult->records() as $dbRecord) {
22
				$typeID = $dbRecord->getInt('hardware_type_id');
23
				self::$CACHE_HARDWARE_TYPES[$typeID] = new self(
24
					typeID: $typeID,
25
					name: $dbRecord->getString('hardware_name'),
26
					cost: $dbRecord->getInt('cost'),
27
				);
28
			}
29
		}
30
		return self::$CACHE_HARDWARE_TYPES;
31
	}
32
33
	public static function get(int $hardwareTypeID): self {
34
		return self::getAll()[$hardwareTypeID];
35
	}
36
37
	public function __construct(
38
		public readonly int $typeID,
39
		public readonly string $name,
40
		public readonly int $cost,
41
	) {}
42
43
}
44