We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 7 | 
| Paths | 36 | 
| Total Lines | 67 | 
| Code Lines | 44 | 
| 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); | ||
| 20 | 	public function build(AbstractSmrPlayer $player, Template $template): void { | ||
| 21 | 		$template->assign('PageTopic', 'Trader Status'); | ||
| 22 | |||
| 23 | Menu::trader(); | ||
| 24 | |||
| 25 | 		if ($player->hasNewbieTurns()) { | ||
| 26 | $container = new NewbieLeave(); | ||
| 27 | 			$template->assign('LeaveNewbieHREF', $container->href()); | ||
| 28 | } | ||
| 29 | |||
| 30 | $container = new TraderRelations(); | ||
| 31 | 		$template->assign('RelationsHREF', $container->href()); | ||
| 32 | |||
| 33 | $container = new TraderSavings(); | ||
| 34 | 		$template->assign('SavingsHREF', $container->href()); | ||
| 35 | |||
| 36 | // Bounties | ||
| 37 | $container = new TraderBounties(); | ||
| 38 | 		$template->assign('BountiesHREF', $container->href()); | ||
| 39 | |||
| 40 | 		$template->assign('BountiesClaimable', count($player->getClaimableBounties())); | ||
| 41 | |||
| 42 | // Ship | ||
| 43 | $container = new HardwareConfigure(); | ||
| 44 | 		$template->assign('HardwareHREF', $container->href()); | ||
| 45 | |||
| 46 | $shipType = $player->getShip()->getType(); | ||
| 47 | $hardwareChecks = [ | ||
| 48 | HARDWARE_SCANNER => $shipType->canHaveScanner(), | ||
| 49 | HARDWARE_ILLUSION => $shipType->canHaveIllusion(), | ||
| 50 | HARDWARE_CLOAK => $shipType->canHaveCloak(), | ||
| 51 | HARDWARE_JUMP => $shipType->canHaveJump(), | ||
| 52 | HARDWARE_DCS => $shipType->canHaveDCS(), | ||
| 53 | ]; | ||
| 54 | $hardware = []; | ||
| 55 | 		foreach ($hardwareChecks as $hardwareTypeID => $shipTypeCanHave) { | ||
| 56 | 			if ($shipTypeCanHave) { | ||
| 57 | $hardware[] = HardwareType::get($hardwareTypeID)->name; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | 		if (empty($hardware)) { | ||
| 61 | $hardware[] = 'none'; | ||
| 62 | } | ||
| 63 | 		$template->assign('Hardware', $hardware); | ||
| 64 | |||
| 65 | 		$template->assign('NextLevel', $player->getLevel()->next()); | ||
| 66 | |||
| 67 | $container = new UserRankingView(); | ||
| 68 | 		$template->assign('UserRankingsHREF', $container->href()); | ||
| 69 | |||
| 70 | $container = new TraderNoteDeleteProcessor(); | ||
| 71 | 		$template->assign('NoteDeleteHREF', $container->href()); | ||
| 72 | |||
| 73 | $notes = []; | ||
| 74 | $db = Database::getInstance(); | ||
| 75 | 		$dbResult = $db->read('SELECT * FROM player_has_notes WHERE ' . $player->getSQL() . ' ORDER BY note_id DESC'); | ||
| 76 | 		foreach ($dbResult->records() as $dbRecord) { | ||
| 77 | 			$note = gzuncompress($dbRecord->getString('note')); | ||
| 78 | 			if ($note === false) { | ||
| 79 | 				throw new Exception('Failed to gzuncompress note!'); | ||
| 80 | } | ||
| 81 | 			$notes[$dbRecord->getInt('note_id')] = $note; | ||
| 82 | } | ||
| 83 | 		$template->assign('Notes', $notes); | ||
| 84 | |||
| 85 | $container = new TraderNoteAddProcessor(); | ||
| 86 | 		$template->assign('NoteAddHREF', $container->href()); | ||
| 87 | } | ||
| 90 |