We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 30 |
| Total Lines | 57 |
| Code Lines | 39 |
| 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); |
||
| 34 | public function build(SmrAccount $account, Template $template): void { |
||
| 35 | $account_id = $this->hofAccountID; |
||
| 36 | $game_id = $this->gameID; |
||
| 37 | $player = null; |
||
| 38 | |||
| 39 | if (isset($game_id)) { |
||
| 40 | try { |
||
| 41 | $player = SmrPlayer::getPlayer($account->getAccountID(), $game_id); |
||
| 42 | } catch (PlayerNotFound) { |
||
| 43 | // Session user is not in this game, $player remains null |
||
| 44 | } |
||
| 45 | |||
| 46 | try { |
||
| 47 | $hofPlayer = SmrPlayer::getPlayer($account_id, $game_id); |
||
| 48 | } catch (PlayerNotFound) { |
||
| 49 | create_error('That player has not yet joined this game.'); |
||
| 50 | } |
||
| 51 | $template->assign('PageTopic', htmlentities($hofPlayer->getPlayerName()) . '\'s Personal Hall of Fame: ' . SmrGame::getGame($game_id)->getDisplayName()); |
||
| 52 | } else { |
||
| 53 | $hofName = SmrAccount::getAccount($account_id)->getHofDisplayName(); |
||
| 54 | $template->assign('PageTopic', $hofName . '\'s All Time Personal Hall of Fame'); |
||
| 55 | } |
||
| 56 | |||
| 57 | $breadcrumb = HallOfFame::buildBreadcrumb($this, 'Personal HoF'); |
||
| 58 | $template->assign('Breadcrumb', $breadcrumb); |
||
| 59 | |||
| 60 | $viewType = $this->viewType ?? ''; |
||
| 61 | $hofVis = SmrPlayer::getHOFVis(); |
||
| 62 | |||
| 63 | if (!isset($hofVis[$viewType])) { |
||
| 64 | // Not a complete HOF type, so continue to show categories |
||
| 65 | $allowedVis = [HOF_PUBLIC]; |
||
| 66 | if ($account->getAccountID() == $account_id) { |
||
| 67 | $allowedVis[] = HOF_ALLIANCE; |
||
| 68 | $allowedVis[] = HOF_PRIVATE; |
||
| 69 | } elseif (isset($hofPlayer) && $hofPlayer->sameAlliance($player)) { |
||
| 70 | $allowedVis[] = HOF_ALLIANCE; |
||
| 71 | } |
||
| 72 | $categories = HallOfFame::getHofCategories($this, $allowedVis, $game_id, $account_id); |
||
| 73 | $template->assign('Categories', $categories); |
||
| 74 | |||
| 75 | } else { |
||
| 76 | // Rankings page |
||
| 77 | $hofRank = HallOfFame::getHofRank($viewType, $account_id, $game_id); |
||
| 78 | $rows = [HallOfFame::displayHOFRow($hofRank['Rank'], $account_id, $game_id, $hofRank['Amount'])]; |
||
| 79 | |||
| 80 | if ($account->getAccountID() != $account_id) { |
||
| 81 | //current player's score. |
||
| 82 | $playerRank = HallOfFame::getHofRank($viewType, $account->getAccountID(), $game_id); |
||
| 83 | $row = HallOfFame::displayHOFRow($playerRank['Rank'], $account->getAccountID(), $game_id, $playerRank['Amount']); |
||
| 84 | if ($playerRank['Rank'] >= $hofRank['Rank']) { |
||
| 85 | $rows[] = $row; |
||
| 86 | } else { |
||
| 87 | array_unshift($rows, $row); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | $template->assign('Rows', $rows); |
||
| 91 | } |
||
| 95 |