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 (#1498)
by Dan
04:47
created

BetaFunctions::build()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 91
Code Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 53
c 0
b 0
f 0
nc 32
nop 2
dl 0
loc 91
rs 8.4032

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types=1);
2
3
namespace Smr\Pages\Player\BetaFunctions;
4
5
use AbstractSmrPlayer;
6
use Globals;
7
use Smr\Page\PlayerPage;
8
use Smr\Page\ReusableTrait;
9
use Smr\Template;
10
use SmrShipType;
11
use SmrWeaponType;
12
13
class BetaFunctions extends PlayerPage {
14
15
	use ReusableTrait;
16
17
	public string $file = 'beta_functions.php';
18
19
	public function build(AbstractSmrPlayer $player, Template $template): void {
20
		if (!ENABLE_BETA) {
21
			create_error('Beta functions are disabled.');
22
		}
23
24
		$sector = $player->getSector();
25
26
		$template->assign('PageTopic', 'Beta Functions');
27
28
		// let them map all
29
		$container = new RevealMapProcessor();
30
		$template->assign('MapHREF', $container->href());
31
32
		// let them get money
33
		$container = new AddMoneyProcessor();
34
		$template->assign('MoneyHREF', $container->href());
35
36
		//next time for ship
37
		$container = new SetShipProcessor();
38
		$template->assign('ShipHREF', $container->href());
39
		$shipList = [];
40
		foreach (SmrShipType::getAll() as $shipTypeID => $shipType) {
41
			$shipList[$shipTypeID] = $shipType->getName();
42
		}
43
		asort($shipList); // sort by name
44
		$template->assign('ShipList', $shipList);
45
46
		//next weapons
47
		$container = new AddWeaponsProcessor();
48
		$template->assign('AddWeaponHREF', $container->href());
49
		$weaponList = [];
50
		foreach (SmrWeaponType::getAllWeaponTypes() as $weaponTypeID => $weaponType) {
51
			$weaponList[$weaponTypeID] = $weaponType->getName();
52
		}
53
		asort($weaponList); // sort by name
54
		$template->assign('WeaponList', $weaponList);
55
56
		//Remove Weapons
57
		$container = new RemoveWeaponsProcessor();
58
		$template->assign('RemoveWeaponsHREF', $container->href());
59
60
		//allow to get full hardware
61
		$container = new RepairShipProcessor();
62
		$template->assign('UnoHREF', $container->href());
63
64
		//move whereever you want
65
		$container = new SetSectorProcessor();
66
		$template->assign('WarpHREF', $container->href());
67
68
		//set turns
69
		$container = new SetTurnsProcessor();
70
		$template->assign('TurnsHREF', $container->href());
71
72
		//set experience
73
		$container = new SetExperienceProcessor();
74
		$template->assign('ExperienceHREF', $container->href());
75
76
		//Set alignment
77
		$container = new SetAlignmentProcessor();
78
		$template->assign('AlignmentHREF', $container->href());
79
80
		//add any type of hardware
81
		$container = new SetHardwareProcessor();
82
		$template->assign('HardwareHREF', $container->href());
83
		$hardware = [];
84
		foreach (Globals::getHardwareTypes() as $hardwareTypeID => $hardwareType) {
85
			$hardware[$hardwareTypeID] = $hardwareType['Name'];
86
		}
87
		$template->assign('Hardware', $hardware);
88
89
		//change personal relations
90
		$container = new SetPersonalRelationsProcessor();
91
		$template->assign('PersonalRelationsHREF', $container->href());
92
93
		//change race relations
94
		$container = new SetPoliticalRelationsProcessor();
95
		$template->assign('RaceRelationsHREF', $container->href());
96
97
		//change race
98
		$container = new SetRaceProcessor();
99
		$template->assign('ChangeRaceHREF', $container->href());
100
101
		if ($sector->hasPlanet()) {
102
			$container = new PlanetBuildingsProcessor();
103
			$template->assign('MaxBuildingsHREF', $container->href());
104
105
			$container = new PlanetDefensesProcessor();
106
			$template->assign('MaxDefensesHREF', $container->href());
107
108
			$container = new PlanetStockpileProcessor();
109
			$template->assign('MaxStockpileHREF', $container->href());
110
		}
111
	}
112
113
}
114