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 (#892)
by Dan
03:48
created

SmrWeaponType::getArmourDamage()   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
/**
4
 * Defines the base weapon types for ships/planets.
5
 */
6
class SmrWeaponType {
7
8
	protected static array $CACHE_WEAPON_TYPES = [];
9
10
	protected int $weaponTypeID;
11
	protected string $name;
12
	protected int $raceID;
13
	protected int $cost;
14
	protected int $shieldDamage;
15
	protected int $armourDamage;
16
	protected int $accuracy;
17
	protected int $powerLevel;
18
	protected int $buyerRestriction;
19
20
	public static function getWeaponType(int $weaponTypeID, SmrMySqlDatabase $db = null) : SmrWeaponType {
21
		if (!isset(self::$CACHE_WEAPON_TYPES[$weaponTypeID])) {
22
			if (is_null($db)) {
23
				$db = new SmrMySqlDatabase();
24
				$db->query('SELECT * FROM weapon_type WHERE weapon_type_id = ' . $db->escapeNumber($weaponTypeID));
25
				$db->requireRecord();
26
			}
27
			$weapon = new SmrWeaponType($weaponTypeID, $db);
28
			self::$CACHE_WEAPON_TYPES[$weaponTypeID] = $weapon;
29
		}
30
		return self::$CACHE_WEAPON_TYPES[$weaponTypeID];
31
	}
32
33
	public static function getAllWeaponTypes() : array {
34
		$db = new SmrMySqlDatabase();
35
		$db->query('SELECT * FROM weapon_type');
36
		$weapons = array();
37
		while ($db->nextRecord()) {
38
			$weapons[] = self::getWeaponType($db->getInt('weapon_type_id'), $db);
39
		}
40
		return $weapons;
41
	}
42
43
	protected function __construct(int $weaponTypeID, SmrMySqlDatabase $db) {
44
		$this->weaponTypeID = $weaponTypeID;
45
		$this->name = $db->getField('weapon_name');
46
		$this->raceID = $db->getInt('race_id');
47
		$this->cost = $db->getInt('cost');
48
		$this->shieldDamage = $db->getInt('shield_damage');
49
		$this->armourDamage = $db->getInt('armour_damage');
50
		$this->accuracy = $db->getInt('accuracy');
51
		$this->powerLevel = $db->getInt('power_level');
52
		$this->buyerRestriction = $db->getInt('buyer_restriction');
53
	}
54
55
	public function getWeaponTypeID() {
56
		return $this->weaponTypeID;
57
	}
58
59
	public function getName() {
60
		return $this->name;
61
	}
62
63
	public function getRaceID() {
64
		return $this->raceID;
65
	}
66
67
	public function getCost() {
68
		return $this->cost;
69
	}
70
71
	public function getShieldDamage() {
72
		return $this->shieldDamage;
73
	}
74
75
	public function getArmourDamage() {
76
		return $this->armourDamage;
77
	}
78
79
	public function getAccuracy() {
80
		return $this->accuracy;
81
	}
82
83
	public function getPowerLevel() {
84
		return $this->powerLevel;
85
	}
86
87
	public function getBuyerRestriction() {
88
		return $this->buyerRestriction;
89
	}
90
91
}
92