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

Passed
Pull Request — master (#1112)
by Dan
04:50
created

Race::getHeadImage()   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 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
/**
6
 * Provides methods to map race IDs to basic race properties.
7
 */
8
class Race {
9
10
	private const RACE_NAMES = [
11
		RACE_NEUTRAL => 'Neutral',
12
		RACE_ALSKANT => 'Alskant',
13
		RACE_CREONTI => 'Creonti',
14
		RACE_HUMAN => 'Human',
15
		RACE_IKTHORNE => 'Ik\'Thorne',
16
		RACE_SALVENE => 'Salvene',
17
		RACE_THEVIAN => 'Thevian',
18
		RACE_WQHUMAN => 'WQ Human',
19
		RACE_NIJARIN => 'Nijarin',
20
	];
21
22
	/**
23
	 * All possible race IDs.
24
	 *
25
	 * @return array<int>
26
	 */
27
	public static function getAllIDs() : array {
28
		return \array_keys(self::RACE_NAMES);
29
	}
30
31
	/**
32
	 * Maps all possible race IDs to race names.
33
	 *
34
	 * @return array<int, string>
35
	 */
36
	public static function getAllNames() : array {
37
		return self::RACE_NAMES;
38
	}
39
40
	/**
41
	 * Race IDs for playable races only. Practically speaking, this is the
42
	 * same as `getAllIDs` with the Neutral race excluded.
43
	 *
44
	 * Note: Some playable races may be excluded on a game-by-game basis
45
	 * by omitting racial HQ locations. See SmrGame::getPlayableRaceIDs.
46
	 *
47
	 * @return array<int>
48
	 */
49
	public static function getPlayableIDs() : array {
50
		$names = self::RACE_NAMES;
51
		unset($names[RACE_NEUTRAL]);
52
		return \array_keys($names);
53
	}
54
55
	/**
56
	 * Maps race IDs to race names for playable races. Practically speaking,
57
	 * this is the same as `getAllNames` with the Neutral race excluded.
58
	 *
59
	 * Note: Some playable races may be excluded on a game-by-game basis
60
	 * by omitting racial HQ locations. See SmrGame::getPlayableRaceIDs.
61
	 *
62
	 * @return array<int, string>
63
	 */
64
	public static function getPlayableNames() : array {
65
		$names = self::RACE_NAMES;
66
		unset($names[RACE_NEUTRAL]);
67
		return $names;
68
	}
69
70
	public static function getName(int $raceID) : string {
71
		return self::RACE_NAMES[$raceID];
72
	}
73
74
	/**
75
	 * Relative path to racial image file.
76
	 */
77
	public static function getImage(int $raceID) : string {
78
		return 'images/race/race' . $raceID . '.jpg';
79
	}
80
81
	/**
82
	 * Relative path to racial image file (portrait version).
83
	 */
84
	public static function getHeadImage(int $raceID) : string {
85
		return 'images/race/head/race' . $raceID . '.jpg';
86
	}
87
88
}
89