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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 37
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAll() 0 14 3
A __construct() 0 5 1
A get() 0 2 1
A clearCache() 0 2 1
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