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 — master (#1018)
by Dan
04:32
created

DummyShip   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
dl 0
loc 47
rs 10
c 1
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A cacheDummyShip() 0 5 1
A __sleep() 0 2 1
A getDummyShipNames() 0 8 2
A __construct() 0 3 1
A getCachedDummyShip() 0 18 4
1
<?php declare(strict_types=1);
2
3
class DummyShip extends AbstractSmrShip {
4
	protected static $CACHED_DUMMY_SHIPS;
5
6
	public function __construct(AbstractSmrPlayer $player) {
7
		parent::__construct($player);
8
		$this->setHardwareToMax();
9
	}
10
11
	public function cacheDummyShip() {
12
		$cache = serialize($this);
13
		$db = MySqlDatabase::getInstance();
14
		$db->query('REPLACE INTO cached_dummys (type, id, info)
15
					VALUES (\'DummyShip\', ' . $db->escapeString($this->getPlayer()->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');
16
	}
17
18
	public static function getCachedDummyShip(AbstractSmrPlayer $player) {
19
		if (!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
20
			$ship = new DummyShip($player);
21
22
			// Load weapons from the dummy database cache, if available
23
			$db = MySqlDatabase::getInstance();
24
			$db->query('SELECT info FROM cached_dummys WHERE type = \'DummyShip\'
25
						AND id = ' . $db->escapeString($player->getPlayerName()) . ' LIMIT 1');
26
			if ($db->nextRecord()) {
27
				$cachedShip = unserialize($db->getField('info'));
28
				foreach ($cachedShip->getWeapons() as $weapon) {
29
					$ship->addWeapon($weapon);
30
				}
31
			}
32
33
			self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = $ship;
34
		}
35
		return self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()];
36
	}
37
38
	public static function getDummyShipNames() {
39
		$db = MySqlDatabase::getInstance();
40
		$db->query('SELECT id FROM cached_dummys WHERE type = \'DummyShip\'');
41
		$dummyNames = array();
42
		while ($db->nextRecord()) {
43
			$dummyNames[] = $db->getField('id');
44
		}
45
		return $dummyNames;
46
	}
47
48
	public function __sleep() {
49
		return array('weapons');
50
	}
51
52
}
53