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
Push — main ( d9cfb9...10f5c7 )
by Dan
32s queued 21s
created

HardwareType::clearCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
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