We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 74 |
| Total Lines | 57 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 | $game_id = $this->gameID; |
||
| 36 | |||
| 37 | if (empty($game_id)) { |
||
| 38 | $topic = 'All Time Hall of Fame'; |
||
| 39 | } else { |
||
| 40 | $topic = 'Hall of Fame: ' . SmrGame::getGame($game_id)->getDisplayName(); |
||
| 41 | } |
||
| 42 | $template->assign('PageTopic', $topic); |
||
| 43 | |||
| 44 | $container = new HallOfFamePersonal($account->getAccountID(), $game_id); |
||
| 45 | $template->assign('PersonalHofHREF', $container->href()); |
||
| 46 | |||
| 47 | $breadcrumb = HallOfFame::buildBreadcrumb($this, isset($game_id) ? 'Current HoF' : 'Global HoF'); |
||
| 48 | $template->assign('Breadcrumb', $breadcrumb); |
||
| 49 | |||
| 50 | $viewType = $this->viewType; |
||
| 51 | $hofVis = SmrPlayer::getHOFVis(); |
||
| 52 | |||
| 53 | if (!isset($hofVis[$viewType])) { |
||
| 54 | // Not a complete HOF type, so continue to show categories |
||
| 55 | $allowedVis = [HOF_PUBLIC, HOF_ALLIANCE]; |
||
| 56 | $categories = HallOfFame::getHofCategories($this, $allowedVis, $game_id, $account->getAccountID()); |
||
| 57 | $template->assign('Categories', $categories); |
||
| 58 | |||
| 59 | } else { |
||
| 60 | // Rankings page |
||
| 61 | $db = Database::getInstance(); |
||
| 62 | $gameIDSql = ' AND game_id ' . (isset($game_id) ? '= ' . $db->escapeNumber($game_id) : 'IN (SELECT game_id FROM game WHERE end_time < ' . Epoch::time() . ' AND ignore_stats = ' . $db->escapeBoolean(false) . ')'); |
||
| 63 | |||
| 64 | $rank = 1; |
||
| 65 | $foundMe = false; |
||
| 66 | |||
| 67 | if ($viewType == HOF_TYPE_DONATION) { |
||
| 68 | $dbResult = $db->read('SELECT account_id, SUM(amount) as amount FROM account_donated |
||
| 69 | GROUP BY account_id ORDER BY amount DESC, account_id ASC LIMIT 25'); |
||
| 70 | } elseif ($viewType == HOF_TYPE_USER_SCORE) { |
||
| 71 | $statements = SmrAccount::getUserScoreCaseStatement($db); |
||
| 72 | $query = 'SELECT account_id, ' . $statements['CASE'] . ' amount FROM (SELECT account_id, type, SUM(amount) amount FROM player_hof WHERE type IN (' . $statements['IN'] . ')' . $gameIDSql . ' GROUP BY account_id,type) x GROUP BY account_id ORDER BY amount DESC, account_id ASC LIMIT 25'; |
||
| 73 | $dbResult = $db->read($query); |
||
| 74 | } else { |
||
| 75 | $dbResult = $db->read('SELECT account_id,SUM(amount) amount FROM player_hof WHERE type=' . $db->escapeString($viewType) . $gameIDSql . ' GROUP BY account_id ORDER BY amount DESC, account_id ASC LIMIT 25'); |
||
| 76 | } |
||
| 77 | $rows = []; |
||
| 78 | foreach ($dbResult->records() as $dbRecord) { |
||
| 79 | $accountID = $dbRecord->getInt('account_id'); |
||
| 80 | if ($accountID == $account->getAccountID()) { |
||
| 81 | $foundMe = true; |
||
| 82 | } |
||
| 83 | $amount = HallOfFame::applyHofVisibilityMask($dbRecord->getFloat('amount'), $hofVis[$viewType], $game_id, $accountID); |
||
| 84 | $rows[] = HallOfFame::displayHOFRow($rank++, $accountID, $game_id, $amount); |
||
| 85 | } |
||
| 86 | if (!$foundMe) { |
||
| 87 | $rank = HallOfFame::getHofRank($viewType, $account->getAccountID(), $game_id); |
||
|
|
|||
| 88 | $rows[] = HallOfFame::displayHOFRow($rank['Rank'], $account->getAccountID(), $game_id, $rank['Amount']); |
||
| 89 | } |
||
| 90 | $template->assign('Rows', $rows); |
||
| 91 | } |
||
| 95 |