We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 12 |
Paths | 10 |
Total Lines | 32 |
Code Lines | 26 |
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); |
||
59 | public static function getMessagePlayer(int $accountID, int $gameID, int $messageType = null): string|SmrPlayer { |
||
60 | if ($accountID == ACCOUNT_ID_PORT) { |
||
61 | $return = '<span class="yellow">Port Defenses</span>'; |
||
62 | } elseif ($accountID == ACCOUNT_ID_ADMIN) { |
||
63 | $return = '<span class="admin">Administrator</span>'; |
||
64 | } elseif ($accountID == ACCOUNT_ID_PLANET) { |
||
65 | $return = '<span class="yellow">Planetary Defenses</span>'; |
||
66 | } elseif ($accountID == ACCOUNT_ID_ALLIANCE_AMBASSADOR) { |
||
67 | $return = '<span class="green">Alliance Ambassador</span>'; |
||
68 | } elseif ($accountID == ACCOUNT_ID_CASINO) { |
||
69 | $return = '<span class="yellow">Casino</span>'; |
||
70 | } elseif ($accountID == ACCOUNT_ID_FED_CLERK) { |
||
71 | $return = '<span class="yellow">Federal Clerk</span>'; |
||
72 | } elseif ($accountID == ACCOUNT_ID_OP_ANNOUNCE || $accountID == ACCOUNT_ID_ALLIANCE_COMMAND) { |
||
73 | $return = '<span class="green">Alliance Command</span>'; |
||
74 | } else { |
||
75 | foreach (Race::getAllNames() as $raceID => $raceName) { |
||
76 | if ($accountID == ACCOUNT_ID_GROUP_RACES + $raceID) { |
||
77 | return '<span class="yellow">' . $raceName . ' Government</span>'; |
||
78 | } |
||
79 | } |
||
80 | if (!empty($accountID)) { |
||
81 | $return = SmrPlayer::getPlayer($accountID, $gameID); |
||
82 | } else { |
||
83 | $return = match ($messageType) { |
||
84 | MSG_ADMIN => '<span class="admin">Administrator</span>', |
||
85 | MSG_ALLIANCE => '<span class="green">Alliance Ambassador</span>', |
||
86 | default => 'Unknown', |
||
87 | }; |
||
88 | } |
||
89 | } |
||
90 | return $return; |
||
91 | } |
||
94 |