Complex classes like Player often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Player, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
17 | class Player extends AvatarModel implements NamedModel, DuplexUrlInterface, EloInterface |
||
18 | { |
||
19 | /** |
||
20 | * These are built-in roles that cannot be deleted via the web interface so we will be storing these values as |
||
21 | * constant variables. Hopefully, a user won't be silly enough to delete them manually from the database. |
||
22 | * |
||
23 | * @TODO Deprecate these and use the Role constants |
||
24 | */ |
||
25 | const DEVELOPER = Role::DEVELOPER; |
||
26 | const ADMIN = Role::ADMINISTRATOR; |
||
27 | const COP = Role::COP; |
||
28 | const REFEREE = Role::REFEREE; |
||
29 | const S_ADMIN = Role::SYSADMIN; |
||
30 | const PLAYER = Role::PLAYER; |
||
31 | const PLAYER_NO_PM = Role::PLAYER_NO_PM; |
||
32 | |||
33 | /** |
||
34 | * The bzid of the player |
||
35 | * @var int |
||
36 | */ |
||
37 | protected $bzid; |
||
38 | |||
39 | /** |
||
40 | * The id of the player's team |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $team; |
||
44 | |||
45 | /** |
||
46 | * The player's e-mail address |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $email; |
||
50 | |||
51 | /** |
||
52 | * Whether the player has verified their e-mail address |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $verified; |
||
56 | |||
57 | /** |
||
58 | * What kind of events the player should be e-mailed about |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $receives; |
||
62 | |||
63 | /** |
||
64 | * A confirmation code for the player's e-mail address verification |
||
65 | * @var string |
||
66 | */ |
||
67 | protected $confirmCode; |
||
68 | |||
69 | /** |
||
70 | * Whether the callsign of the player is outdated |
||
71 | * @var bool |
||
72 | */ |
||
73 | protected $outdated; |
||
74 | |||
75 | /** |
||
76 | * The player's profile description |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $description; |
||
80 | |||
81 | /** |
||
82 | * The id of the player's country |
||
83 | * @var int |
||
84 | */ |
||
85 | protected $country; |
||
86 | |||
87 | /** |
||
88 | * The site theme this player has chosen |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $theme; |
||
92 | |||
93 | /** |
||
94 | * The player's timezone PHP identifier, e.g. "Europe/Paris" |
||
95 | * @var string |
||
96 | */ |
||
97 | protected $timezone; |
||
98 | |||
99 | /** |
||
100 | * The date the player joined the site |
||
101 | * @var TimeDate |
||
102 | */ |
||
103 | protected $joined; |
||
104 | |||
105 | /** |
||
106 | * The date of the player's last login |
||
107 | * @var TimeDate |
||
108 | */ |
||
109 | protected $last_login; |
||
110 | |||
111 | /** |
||
112 | * The date of the player's last match |
||
113 | * @var Match |
||
114 | */ |
||
115 | protected $last_match; |
||
116 | |||
117 | /** |
||
118 | * The roles a player belongs to |
||
119 | * @var Role[] |
||
120 | */ |
||
121 | protected $roles; |
||
122 | |||
123 | /** |
||
124 | * The permissions a player has |
||
125 | * @var Permission[] |
||
126 | */ |
||
127 | protected $permissions; |
||
128 | |||
129 | /** |
||
130 | * A section for admins to write notes about players |
||
131 | * @var string |
||
132 | */ |
||
133 | protected $admin_notes; |
||
134 | |||
135 | /** |
||
136 | * The ban of the player, or null if the player is not banned |
||
137 | * @var Ban|null |
||
138 | */ |
||
139 | protected $ban; |
||
140 | |||
141 | /** |
||
142 | * Cached results for match summaries |
||
143 | * |
||
144 | * @var array |
||
145 | */ |
||
146 | private $cachedMatchSummary; |
||
147 | |||
148 | /** |
||
149 | * The cached match count for a player |
||
150 | * |
||
151 | * @var int |
||
152 | */ |
||
153 | private $cachedMatchCount = null; |
||
154 | |||
155 | /** |
||
156 | * The Elo for this player that has been explicitly set for this player from a database query. This value will take |
||
157 | * precedence over having to build to an Elo season history. |
||
158 | * |
||
159 | * @var int |
||
160 | */ |
||
161 | private $elo; |
||
162 | private $eloSeason; |
||
163 | private $eloSeasonHistory; |
||
164 | |||
165 | private $matchActivity; |
||
166 | |||
167 | /** |
||
168 | * The name of the database table used for queries |
||
169 | */ |
||
170 | const TABLE = "players"; |
||
171 | |||
172 | /** |
||
173 | * The location where avatars will be stored |
||
174 | */ |
||
175 | const AVATAR_LOCATION = "/web/assets/imgs/avatars/players/"; |
||
176 | |||
177 | 76 | const EDIT_PERMISSION = Permission::EDIT_USER; |
|
178 | const SOFT_DELETE_PERMISSION = Permission::SOFT_DELETE_USER; |
||
179 | 76 | const HARD_DELETE_PERMISSION = Permission::HARD_DELETE_USER; |
|
180 | 76 | ||
181 | 76 | /** |
|
182 | 76 | * {@inheritdoc} |
|
183 | 76 | */ |
|
184 | 76 | protected function assignResult($player) |
|
202 | 76 | ||
203 | 76 | /** |
|
204 | 76 | * {@inheritdoc} |
|
205 | 76 | */ |
|
206 | 76 | protected function assignLazyResult($player) |
|
233 | 14 | ||
234 | /** |
||
235 | * Add a player a new role |
||
236 | * |
||
237 | 76 | * @param Role|int $role_id The role ID to add a player to |
|
238 | 76 | * |
|
239 | * @return bool Whether the operation was successful or not |
||
240 | 76 | */ |
|
241 | public function addRole($role_id) |
||
261 | |||
262 | /** |
||
263 | * Get the notes admins have left about a player |
||
264 | * @return string The notes |
||
265 | */ |
||
266 | public function getAdminNotes() |
||
272 | |||
273 | /** |
||
274 | * Get the player's BZID |
||
275 | * @return int The BZID |
||
276 | */ |
||
277 | public function getBZID() |
||
281 | |||
282 | /** |
||
283 | * Get the country a player belongs to |
||
284 | * |
||
285 | * @return Country The country belongs to |
||
286 | */ |
||
287 | public function getCountry() |
||
291 | |||
292 | /** |
||
293 | 30 | * Get the e-mail address of the player |
|
294 | * |
||
295 | 30 | * @return string The address |
|
296 | 29 | */ |
|
297 | public function getEmailAddress() |
||
303 | 30 | ||
304 | /** |
||
305 | * Build a key that we'll use for caching season Elo data in this model |
||
306 | * |
||
307 | * @param string|null $season The season to get |
||
308 | * @param int|null $year The year of the season to get |
||
309 | * |
||
310 | * @return string |
||
311 | */ |
||
312 | private function buildSeasonKey(&$season, &$year) |
||
324 | |||
325 | /** |
||
326 | * Build a key to use for caching season Elo data in this model from a timestamp |
||
327 | * |
||
328 | * @param DateTime $timestamp |
||
329 | * |
||
330 | * @return string |
||
331 | */ |
||
332 | 3 | private function buildSeasonKeyFromTimestamp(\DateTime $timestamp) |
|
338 | |||
339 | 3 | /** |
|
340 | 2 | * Remove all Elo data for this model for matches occurring after the given match (inclusive) |
|
341 | * |
||
342 | * This function will not remove the Elo data for this match from the database. Ideally, this function should only |
||
343 | * be called during Elo recalculation for this match. |
||
344 | * |
||
345 | 3 | * @internal |
|
346 | * |
||
347 | 3 | * @param Match $match |
|
348 | 1 | * |
|
349 | * @see Match::recalculateElo() |
||
350 | */ |
||
351 | public function invalidateMatchFromCache(Match $match) |
||
379 | |||
380 | /** |
||
381 | * Get the Elo changes for a player for a given season |
||
382 | * |
||
383 | * @param string|null $season The season to get |
||
384 | * @param int|null $year The year of the season to get |
||
385 | * |
||
386 | * @return array |
||
387 | */ |
||
388 | public function getEloSeasonHistory($season = null, $year = null) |
||
423 | |||
424 | 30 | /** |
|
425 | * Get the player's Elo for a season. |
||
426 | 30 | * |
|
427 | 30 | * With the default arguments, it will fetch the Elo for the current season. |
|
428 | 30 | * |
|
429 | * @param string|null $season The season we're looking for: winter, spring, summer, or fall |
||
430 | * @param int|null $year The year of the season we're looking for |
||
431 | * |
||
432 | * @return int The player's Elo |
||
433 | 30 | */ |
|
434 | public function getElo($season = null, $year = null) |
||
459 | 29 | ||
460 | /** |
||
461 | 30 | * Adjust the Elo of a player for the current season based on a Match |
|
462 | * |
||
463 | * **Warning:** If $match is null, the Elo for the player will be modified but the value will not be persisted to |
||
464 | * the database. |
||
465 | * |
||
466 | * @param int $adjust The value to be added to the current ELO (negative to subtract) |
||
467 | * @param Match|null $match The match where this Elo change took place |
||
468 | */ |
||
469 | public function adjustElo($adjust, Match $match = null) |
||
486 | |||
487 | /** |
||
488 | * Returns whether the player has verified their e-mail address |
||
489 | * |
||
490 | * @return bool `true` for verified players |
||
491 | */ |
||
492 | public function isVerified() |
||
498 | |||
499 | /** |
||
500 | * Returns the confirmation code for the player's e-mail address verification |
||
501 | * |
||
502 | * @return string The player's confirmation code |
||
503 | */ |
||
504 | public function getConfirmCode() |
||
510 | 1 | ||
511 | /** |
||
512 | 1 | * Returns what kind of events the player should be e-mailed about |
|
513 | * |
||
514 | * @return string The type of notifications |
||
515 | */ |
||
516 | public function getReceives() |
||
522 | |||
523 | /** |
||
524 | * Finds out whether the specified player wants and can receive an e-mail |
||
525 | * message |
||
526 | * |
||
527 | * @param string $type |
||
528 | * @return bool `true` if the player should be sent an e-mail |
||
529 | */ |
||
530 | public function canReceive($type) |
||
545 | |||
546 | /** |
||
547 | * Find out whether the specified confirmation code is correct |
||
548 | * |
||
549 | * This method protects against timing attacks |
||
550 | * |
||
551 | * @param string $code The confirmation code to check |
||
552 | * @return bool `true` for a correct e-mail verification code |
||
553 | */ |
||
554 | public function isCorrectConfirmCode($code) |
||
564 | |||
565 | /** |
||
566 | * Get the player's sanitized description |
||
567 | * @return string The description |
||
568 | */ |
||
569 | public function getDescription() |
||
575 | |||
576 | /** |
||
577 | * Get the joined date of the player |
||
578 | * @return TimeDate The joined date of the player |
||
579 | */ |
||
580 | public function getJoinedDate() |
||
586 | |||
587 | /** |
||
588 | * Get all of the known IPs used by the player |
||
589 | * |
||
590 | * @return string[][] An array containing IPs and hosts |
||
591 | */ |
||
592 | public function getKnownIPs() |
||
599 | |||
600 | /** |
||
601 | * Get the last login for a player |
||
602 | * @return TimeDate The date of the last login |
||
603 | */ |
||
604 | public function getLastLogin() |
||
610 | |||
611 | 23 | /** |
|
612 | * Get the last match |
||
613 | 23 | * @return Match |
|
614 | */ |
||
615 | public function getLastMatch() |
||
621 | |||
622 | 1 | /** |
|
623 | * Get all of the callsigns a player has used to log in to the website |
||
624 | 1 | * @return string[] An array containing all of the past callsigns recorded for a player |
|
625 | */ |
||
626 | public function getPastCallsigns() |
||
630 | |||
631 | /** |
||
632 | * Get the player's team |
||
633 | * @return Team The object representing the team |
||
634 | */ |
||
635 | public function getTeam() |
||
639 | |||
640 | /** |
||
641 | 76 | * Get the player's timezone PHP identifier (example: "Europe/Paris") |
|
642 | * @return string The timezone |
||
643 | 76 | */ |
|
644 | 76 | public function getTimezone() |
|
650 | |||
651 | /** |
||
652 | * Get the roles of the player |
||
653 | * @return Role[] |
||
654 | */ |
||
655 | public function getRoles() |
||
661 | 1 | ||
662 | /** |
||
663 | * Rebuild the list of permissions a user has been granted |
||
664 | 2 | */ |
|
665 | private function updateUserPermissions() |
||
674 | |||
675 | /** |
||
676 | * Check if a player has a specific permission |
||
677 | * |
||
678 | * @param string|null $permission The permission to check for |
||
679 | * |
||
680 | * @return bool Whether or not the player has the permission |
||
681 | */ |
||
682 | public function hasPermission($permission) |
||
692 | |||
693 | /** |
||
694 | * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered |
||
695 | * active |
||
696 | * |
||
697 | * @return bool True if the player has been active |
||
698 | */ |
||
699 | public function hasBeenActive() |
||
715 | |||
716 | /** |
||
717 | * Check whether the callsign of the player is outdated |
||
718 | * |
||
719 | * Returns true if this player has probably changed their callsign, making |
||
720 | * the current username stored in the database obsolete |
||
721 | * |
||
722 | 1 | * @return bool Whether or not the player is disabled |
|
723 | */ |
||
724 | 1 | public function isOutdated() |
|
730 | |||
731 | /** |
||
732 | 55 | * Check if a player's account has been disabled |
|
733 | * |
||
734 | 55 | * @return bool Whether or not the player is disabled |
|
735 | */ |
||
736 | public function isDisabled() |
||
740 | 1 | ||
741 | /** |
||
742 | 1 | * Check if everyone can log in as this user on a test environment |
|
743 | * |
||
744 | * @return bool |
||
745 | */ |
||
746 | 1 | public function isTestUser() |
|
750 | |||
751 | /** |
||
752 | * Check if a player is teamless |
||
753 | * |
||
754 | * @return bool True if the player is teamless |
||
755 | */ |
||
756 | public function isTeamless() |
||
760 | |||
761 | /** |
||
762 | * Mark a player's account as banned |
||
763 | */ |
||
764 | public function markAsBanned() |
||
772 | |||
773 | /** |
||
774 | * Mark a player's account as unbanned |
||
775 | */ |
||
776 | public function markAsUnbanned() |
||
784 | |||
785 | /** |
||
786 | * Find out if a player is banned |
||
787 | * |
||
788 | * @return bool |
||
789 | */ |
||
790 | public function isBanned() |
||
794 | |||
795 | /** |
||
796 | * Get the ban of the player |
||
797 | * |
||
798 | * This method performs a load of all the lazy parameters of the Player |
||
799 | * |
||
800 | * @return Ban|null The current ban of the player, or null if the player is |
||
801 | * is not banned |
||
802 | */ |
||
803 | public function getBan() |
||
809 | |||
810 | /** |
||
811 | * Remove a player from a role |
||
812 | * |
||
813 | * @param int $role_id The role ID to add or remove |
||
814 | * |
||
815 | * @return bool Whether the operation was successful or not |
||
816 | */ |
||
817 | public function removeRole($role_id) |
||
824 | |||
825 | /** |
||
826 | * Set the player's email address and reset their verification status |
||
827 | * @param string $email The address |
||
828 | */ |
||
829 | public function setEmailAddress($email) |
||
843 | |||
844 | /** |
||
845 | * Set whether the player has verified their e-mail address |
||
846 | * |
||
847 | * @param bool $verified Whether the player is verified or not |
||
848 | * @return self |
||
849 | */ |
||
850 | public function setVerified($verified) |
||
860 | |||
861 | /** |
||
862 | * Generate a new random confirmation token for e-mail address verification |
||
863 | * |
||
864 | * @return self |
||
865 | */ |
||
866 | public function generateNewConfirmCode() |
||
873 | |||
874 | /** |
||
875 | * Set the confirmation token for e-mail address verification |
||
876 | * |
||
877 | * @param string $code The confirmation code |
||
878 | * @return self |
||
879 | */ |
||
880 | private function setConfirmCode($code) |
||
886 | 76 | ||
887 | /** |
||
888 | * Set what kind of events the player should be e-mailed about |
||
889 | * |
||
890 | * @param string $receives The type of notification |
||
891 | * @return self |
||
892 | */ |
||
893 | public function setReceives($receives) |
||
899 | |||
900 | /** |
||
901 | * Set whether the callsign of the player is outdated |
||
902 | * |
||
903 | * @param bool $outdated Whether the callsign is outdated |
||
904 | * @return self |
||
905 | */ |
||
906 | public function setOutdated($outdated) |
||
912 | |||
913 | 55 | /** |
|
914 | 55 | * Set the player's description |
|
915 | * @param string $description The description |
||
916 | */ |
||
917 | public function setDescription($description) |
||
921 | 29 | ||
922 | /** |
||
923 | 29 | * Set the player's timezone |
|
924 | 29 | * @param string $timezone The timezone |
|
925 | */ |
||
926 | public function setTimezone($timezone) |
||
930 | |||
931 | /** |
||
932 | * Set the player's team |
||
933 | * @param int $team The team's ID |
||
934 | */ |
||
935 | public function setTeam($team) |
||
939 | |||
940 | /** |
||
941 | * Set the match the player last participated in |
||
942 | * |
||
943 | * @param int $match The match's ID |
||
944 | */ |
||
945 | public function setLastMatch($match) |
||
949 | |||
950 | /** |
||
951 | * Set the player's status |
||
952 | * @param string $status The new status |
||
953 | */ |
||
954 | public function setStatus($status) |
||
958 | |||
959 | /** |
||
960 | * Set the player's admin notes |
||
961 | * @param string $admin_notes The new admin notes |
||
962 | * @return self |
||
963 | */ |
||
964 | public function setAdminNotes($admin_notes) |
||
968 | |||
969 | 1 | /** |
|
970 | * Set the player's country |
||
971 | * @param int $country The ID of the new country |
||
972 | * @return self |
||
973 | */ |
||
974 | public function setCountry($country) |
||
978 | 1 | ||
979 | /** |
||
980 | * Get the player's chosen theme preference |
||
981 | * |
||
982 | * @return string |
||
983 | */ |
||
984 | public function getTheme() |
||
990 | |||
991 | /** |
||
992 | * Set the site theme for the player |
||
993 | * |
||
994 | * If the chosen site theme is invalid, it'll be defaulted to the site default (the first theme defined) |
||
995 | * |
||
996 | * @param string $theme |
||
997 | */ |
||
998 | public function setTheme($theme) |
||
1008 | |||
1009 | /** |
||
1010 | * Updates this player's last login |
||
1011 | */ |
||
1012 | public function updateLastLogin() |
||
1016 | |||
1017 | /** |
||
1018 | * Get the player's username |
||
1019 | * @return string The username |
||
1020 | */ |
||
1021 | public function getUsername() |
||
1025 | |||
1026 | /** |
||
1027 | * Get the player's username, safe for use in your HTML |
||
1028 | * @return string The username |
||
1029 | */ |
||
1030 | public function getEscapedUsername() |
||
1034 | |||
1035 | /** |
||
1036 | * Alias for Player::setUsername() |
||
1037 | * |
||
1038 | * @param string $username The new username |
||
1039 | * @return self |
||
1040 | */ |
||
1041 | public function setName($username) |
||
1045 | |||
1046 | 76 | /** |
|
1047 | * Mark all the unread messages of a player as read |
||
1048 | 76 | * |
|
1049 | 76 | * @return void |
|
1050 | 76 | */ |
|
1051 | public function markMessagesAsRead() |
||
1058 | |||
1059 | /** |
||
1060 | * Set the roles of a user |
||
1061 | * |
||
1062 | * @todo Is it worth making this faster? |
||
1063 | * @param Role[] $roles The new roles of the user |
||
1064 | * @return self |
||
1065 | */ |
||
1066 | public function setRoles($roles) |
||
1089 | |||
1090 | /** |
||
1091 | * Give or remove a role to/form a player |
||
1092 | * |
||
1093 | * @param int $role_id The role ID to add or remove |
||
1094 | * @param string $action Whether to "add" or "remove" a role for a player |
||
1095 | * |
||
1096 | * @return bool Whether the operation was successful or not |
||
1097 | */ |
||
1098 | private function modifyRole($role_id, $action) |
||
1116 | |||
1117 | /** |
||
1118 | * Given a player's BZID, get a player object |
||
1119 | * |
||
1120 | * @param int $bzid The player's BZID |
||
1121 | * @return Player |
||
1122 | */ |
||
1123 | public static function getFromBZID($bzid) |
||
1127 | |||
1128 | /** |
||
1129 | * Get a single player by their username |
||
1130 | * |
||
1131 | * @param string $username The username to look for |
||
1132 | * @return Player |
||
1133 | */ |
||
1134 | public static function getFromUsername($username) |
||
1140 | |||
1141 | /** |
||
1142 | * Get all the players in the database that have an active status |
||
1143 | * @return Player[] An array of player BZIDs |
||
1144 | */ |
||
1145 | public static function getPlayers() |
||
1151 | |||
1152 | /** |
||
1153 | * Show the number of notifications the user hasn't read yet |
||
1154 | * @return int |
||
1155 | */ |
||
1156 | public function countUnreadNotifications() |
||
1160 | |||
1161 | /** |
||
1162 | * Count the number of matches a player has participated in |
||
1163 | * @return int |
||
1164 | */ |
||
1165 | public function getMatchCount() |
||
1176 | |||
1177 | /** |
||
1178 | * Get the (victory/total matches) ratio of the player |
||
1179 | * @return float |
||
1180 | */ |
||
1181 | public function getMatchWinRatio() |
||
1196 | |||
1197 | /** |
||
1198 | * Get the (total caps made by team/total matches) ratio of the player |
||
1199 | * @return float |
||
1200 | */ |
||
1201 | public function getMatchAverageCaps() |
||
1202 | { |
||
1203 | $count = $this->getMatchCount(); |
||
1204 | |||
1205 | if ($count == 0) { |
||
1206 | return 0; |
||
1207 | } |
||
1208 | |||
1209 | // Get the sum of team A points if the player was in team A, team B points if the player was in team B |
||
1210 | $query = $this->db->query(" |
||
1211 | SELECT |
||
1212 | SUM( |
||
1213 | IF(mp.team_loyalty = 0, team_a_points, team_b_points) |
||
1214 | ) AS sum |
||
1215 | FROM |
||
1216 | matches |
||
1217 | INNER JOIN |
||
1218 | match_participation mp ON mp.match_id = matches.id |
||
1219 | WHERE |
||
1220 | status = 'entered' AND mp.user_id = ? |
||
1221 | ", [$this->id]); |
||
1222 | |||
1223 | return $query[0]['sum'] / $count; |
||
1224 | } |
||
1225 | |||
1226 | /** |
||
1227 | * Get the match activity in matches per day for a player |
||
1228 | * |
||
1229 | 1 | * @return float |
|
1230 | */ |
||
1231 | 1 | public function getMatchActivity() |
|
1251 | 1 | ||
1252 | /** |
||
1253 | 1 | * Return an array of matches this player participated in per month. |
|
1254 | * |
||
1255 | * ``` |
||
1256 | * ['yyyy-mm'] = <number of matches> |
||
1257 | * ``` |
||
1258 | * |
||
1259 | 76 | * @param TimeDate|string $timePeriod |
|
1260 | * |
||
1261 | * @return int[] |
||
1262 | 76 | */ |
|
1263 | public function getMatchSummary($timePeriod = '1 year ago') |
||
1278 | 76 | ||
1279 | /** |
||
1280 | * Show the number of messages the user hasn't read yet |
||
1281 | 76 | * @return int |
|
1282 | */ |
||
1283 | public function countUnreadMessages() |
||
1289 | |||
1290 | /** |
||
1291 | * Get all of the members belonging to a team |
||
1292 | * @param int $teamID The ID of the team to fetch the members of |
||
1293 | * @return Player[] An array of Player objects of the team members |
||
1294 | 76 | */ |
|
1295 | public static function getTeamMembers($teamID) |
||
1301 | |||
1302 | /** |
||
1303 | * {@inheritdoc} |
||
1304 | */ |
||
1305 | public static function getActiveStatuses() |
||
1309 | |||
1310 | /** |
||
1311 | * {@inheritdoc} |
||
1312 | */ |
||
1313 | public static function getEagerColumns($prefix = null) |
||
1328 | |||
1329 | 76 | /** |
|
1330 | * {@inheritdoc} |
||
1331 | 76 | */ |
|
1332 | 76 | public static function getLazyColumns($prefix = null) |
|
1351 | 76 | ||
1352 | /** |
||
1353 | 76 | * Get a query builder for players |
|
1354 | * @return PlayerQueryBuilder |
||
1355 | */ |
||
1356 | public static function getQueryBuilder() |
||
1368 | |||
1369 | /** |
||
1370 | * Enter a new player to the database |
||
1371 | * @param int $bzid The player's bzid |
||
1372 | * @param string $username The player's username |
||
1373 | 76 | * @param int $team The player's team |
|
1374 | * @param string $status The player's status |
||
1375 | * @param int $role_id The player's role when they are first created |
||
1376 | * @param string $avatar The player's profile avatar |
||
1377 | 76 | * @param string $description The player's profile description |
|
1378 | * @param int $country The player's country |
||
1379 | * @param string $timezone The player's timezone |
||
1380 | 76 | * @param string|\TimeDate $joined The date the player joined |
|
1381 | * @param string|\TimeDate $last_login The timestamp of the player's last login |
||
1382 | 76 | * @return Player An object representing the player that was just entered |
|
1383 | */ |
||
1384 | 76 | public static function newPlayer($bzid, $username, $team = null, $status = "active", $role_id = self::PLAYER, $avatar = "", $description = "", $country = 1, $timezone = null, $joined = "now", $last_login = "now") |
|
1410 | |||
1411 | 1 | /** |
|
1412 | 1 | * Determine if a player exists in the database |
|
1413 | 1 | * @param int $bzid The player's bzid |
|
1414 | * @return bool Whether the player exists in the database |
||
1415 | */ |
||
1416 | public static function playerBZIDExists($bzid) |
||
1420 | 76 | ||
1421 | /** |
||
1422 | 76 | * Change a player's callsign and add it to the database if it does not |
|
1423 | * exist as a past callsign |
||
1424 | 76 | * |
|
1425 | 76 | * @param string $username The new username of the player |
|
1426 | * @return self |
||
1427 | */ |
||
1428 | public function setUsername($username) |
||
1459 | |||
1460 | /** |
||
1461 | * Alphabetical order function for use in usort (case-insensitive) |
||
1462 | 1 | * @return Closure The sort function |
|
1463 | */ |
||
1464 | 1 | public static function getAlphabeticalSort() |
|
1470 | |||
1471 | /** |
||
1472 | * {@inheritdoc} |
||
1473 | 1 | * @todo Add a constraint that does this automatically |
|
1474 | */ |
||
1475 | 1 | public function wipe() |
|
1481 | |||
1482 | /** |
||
1483 | * Find whether the player can delete a model |
||
1484 | * |
||
1485 | * @param PermissionModel $model The model that will be seen |
||
1486 | * @param bool $showDeleted Whether to show deleted models to admins |
||
1487 | * @return bool |
||
1488 | */ |
||
1489 | public function canSee($model, $showDeleted = false) |
||
1493 | |||
1494 | /** |
||
1495 | * Find whether the player can delete a model |
||
1496 | * |
||
1497 | * @param PermissionModel $model The model that will be deleted |
||
1498 | * @param bool $hard Whether to check for hard-delete perms, as opposed |
||
1499 | * to soft-delete ones |
||
1500 | * @return bool |
||
1501 | */ |
||
1502 | public function canDelete($model, $hard = false) |
||
1510 | |||
1511 | /** |
||
1512 | * Find whether the player can create a model |
||
1513 | * |
||
1514 | * @param string $modelName The PHP class identifier of the model type |
||
1515 | * @return bool |
||
1516 | */ |
||
1517 | public function canCreate($modelName) |
||
1521 | |||
1522 | /** |
||
1523 | * Find whether the player can edit a model |
||
1524 | * |
||
1525 | * @param PermissionModel $model The model which will be edited |
||
1526 | * @return bool |
||
1527 | */ |
||
1528 | public function canEdit($model) |
||
1532 | } |
||
1533 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..