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 (#1494)
by Dan
10:59 queued 05:29
created

OwnershipProcessor   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B build() 0 40 8
1
<?php declare(strict_types=1);
2
3
namespace Smr\Pages\Player\Planet;
4
5
use AbstractSmrPlayer;
6
use Smr\Database;
7
use Smr\Page\PlayerPageProcessor;
8
use Smr\Request;
9
10
class OwnershipProcessor extends PlayerPageProcessor {
11
12
	public function build(AbstractSmrPlayer $player): never {
13
		if (!$player->isLandedOnPlanet()) {
14
			create_error('You are not on a planet!');
15
		}
16
		// get a planet from the sector where the player is in
17
		$planet = $player->getSectorPlanet();
18
		$action = Request::get('action');
19
20
		if ($action == 'Take Ownership') {
21
			if ($planet->hasOwner() && $planet->getPassword() != Request::get('password')) {
22
				create_error('You entered an incorrect password for this planet!');
23
			}
24
25
			// delete all previous ownerships
26
			$db = Database::getInstance();
27
			$db->write('UPDATE planet SET owner_id = 0, password = NULL
28
						WHERE owner_id = ' . $db->escapeNumber($player->getAccountID()) . '
29
						AND game_id = ' . $db->escapeNumber($player->getGameID()));
30
31
			// set ownership
32
			$planet->setOwnerID($player->getAccountID());
33
			$planet->removePassword();
34
			$player->log(LOG_TYPE_PLANETS, 'Player takes ownership of planet.');
35
		} elseif ($action == 'Rename') {
36
			$name = Request::get('name');
37
			if (empty($name)) {
38
				create_error('You cannot leave your planet nameless!');
39
			}
40
			// rename planet
41
			$planet->setName($name);
42
			$player->log(LOG_TYPE_PLANETS, 'Player renames planet to ' . $name . '.');
43
44
		} elseif ($action == 'Set Password') {
45
			// set password
46
			$password = Request::get('password');
47
			$planet->setPassword($password);
48
			$player->log(LOG_TYPE_PLANETS, 'Player sets planet password to ' . $password);
49
		}
50
51
		(new Ownership())->go();
52
	}
53
54
}
55