We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 6 |
Paths | 32 |
Total Lines | 91 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php declare(strict_types=1); |
||
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 | } |
||
114 |