We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 20 |
Paths | 2322 |
Total Lines | 87 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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); |
||
25 | public function build(SmrAccount $account, Template $template): void { |
||
26 | $this->galaxyID ??= Request::getInt('gal_on'); |
||
27 | $template->assign('Galaxies', SmrGalaxy::getGameGalaxies($this->gameID)); |
||
28 | |||
29 | $container = new self($this->gameID); |
||
30 | $template->assign('JumpGalaxyHREF', $container->href()); |
||
31 | |||
32 | $locations = SmrLocation::getAllLocations($this->gameID); |
||
33 | |||
34 | // Initialize all location counts to zero |
||
35 | $totalLocs = []; |
||
36 | foreach ($locations as $location) { |
||
37 | $totalLocs[$location->getTypeID()] = 0; |
||
38 | } |
||
39 | |||
40 | $galaxy = SmrGalaxy::getGalaxy($this->gameID, $this->galaxyID); |
||
41 | $template->assign('Galaxy', $galaxy); |
||
42 | |||
43 | // Determine the current amount of each location |
||
44 | foreach ($galaxy->getSectors() as $galSector) { |
||
45 | foreach ($galSector->getLocations() as $sectorLocation) { |
||
46 | $totalLocs[$sectorLocation->getTypeID()]++; |
||
47 | } |
||
48 | } |
||
49 | $template->assign('TotalLocs', $totalLocs); |
||
50 | |||
51 | // Remove any linked locations, as they will be added automatically |
||
52 | // with any corresponding HQs. |
||
53 | foreach ($locations as $location) { |
||
54 | foreach ($location->getLinkedLocations() as $linkedLoc) { |
||
55 | unset($locations[$linkedLoc->getTypeID()]); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | // Set any extra information to be displayed with each location |
||
60 | $locText = []; |
||
61 | $categories = new UniGenLocationCategories(); |
||
62 | foreach ($locations as $location) { |
||
63 | $extra = '<span class="small"><br />'; |
||
64 | if ($location->isWeaponSold()) { |
||
65 | $extra .= $categories->addLoc($location->getTypeID(), 'Weapons'); |
||
66 | foreach ($location->getWeaponsSold() as $weapon) { |
||
67 | $extra .= $weapon->getName() . ' (' . $weapon->getShieldDamage() . '/' . $weapon->getArmourDamage() . '/' . $weapon->getBaseAccuracy() . ')<br />'; |
||
68 | } |
||
69 | } |
||
70 | if ($location->isShipSold()) { |
||
71 | $extra .= $categories->addLoc($location->getTypeID(), 'Ships'); |
||
72 | foreach ($location->getShipsSold() as $shipSold) { |
||
73 | $extra .= $shipSold->getName() . '<br />'; |
||
74 | } |
||
75 | } |
||
76 | if ($location->isHardwareSold()) { |
||
77 | $extra .= $categories->addLoc($location->getTypeID(), 'Hardware'); |
||
78 | foreach ($location->getHardwareSold() as $hardware) { |
||
79 | $extra .= $hardware['Name'] . '<br />'; |
||
80 | } |
||
81 | } |
||
82 | if ($location->isBar()) { |
||
83 | $extra .= $categories->addLoc($location->getTypeID(), 'Bars'); |
||
84 | } |
||
85 | if ($location->isBank()) { |
||
86 | $extra .= $categories->addLoc($location->getTypeID(), 'Banks'); |
||
87 | } |
||
88 | if ($location->isHQ() || $location->isUG() || $location->isFed()) { |
||
89 | $extra .= $categories->addLoc($location->getTypeID(), 'Headquarters'); |
||
90 | foreach ($location->getLinkedLocations() as $linkedLoc) { |
||
91 | $extra .= $linkedLoc->getName() . '<br />'; |
||
92 | } |
||
93 | } |
||
94 | if (!$categories->added($location->getTypeID())) { |
||
95 | // Anything that doesn't fit the other categories |
||
96 | $extra .= $categories->addLoc($location->getTypeID(), 'Miscellaneous'); |
||
97 | } |
||
98 | $extra .= '</span>'; |
||
99 | |||
100 | $locText[$location->getTypeID()] = $location->getName() . $extra; |
||
101 | } |
||
102 | $template->assign('LocText', $locText); |
||
103 | $template->assign('LocTypes', $categories->locTypes); |
||
104 | |||
105 | // Form to make location changes |
||
106 | $container = new SaveProcessor($this->gameID, $this->galaxyID); |
||
107 | $template->assign('CreateLocationsFormHREF', $container->href()); |
||
108 | |||
109 | // HREF to cancel and return to the previous page |
||
110 | $container = new EditGalaxy($this->gameID, $this->galaxyID); |
||
111 | $template->assign('CancelHREF', $container->href()); |
||
112 | } |
||
115 |