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 status |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $status; |
||
50 | |||
51 | /** |
||
52 | * The player's e-mail address |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $email; |
||
56 | |||
57 | /** |
||
58 | * Whether the player has verified their e-mail address |
||
59 | * @var bool |
||
60 | */ |
||
61 | protected $verified; |
||
62 | |||
63 | /** |
||
64 | * What kind of events the player should be e-mailed about |
||
65 | * @var string |
||
66 | */ |
||
67 | protected $receives; |
||
68 | |||
69 | /** |
||
70 | * A confirmation code for the player's e-mail address verification |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $confirmCode; |
||
74 | |||
75 | /** |
||
76 | * Whether the callsign of the player is outdated |
||
77 | * @var bool |
||
78 | */ |
||
79 | protected $outdated; |
||
80 | |||
81 | /** |
||
82 | * The player's profile description |
||
83 | * @var string |
||
84 | */ |
||
85 | protected $description; |
||
86 | |||
87 | /** |
||
88 | * The id of the player's country |
||
89 | * @var int |
||
90 | */ |
||
91 | protected $country; |
||
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 | private $eloSeason; |
||
156 | private $eloSeasonHistory; |
||
157 | |||
158 | private $matchActivity; |
||
159 | |||
160 | /** |
||
161 | * The name of the database table used for queries |
||
162 | */ |
||
163 | const TABLE = "players"; |
||
164 | |||
165 | /** |
||
166 | * The location where avatars will be stored |
||
167 | */ |
||
168 | const AVATAR_LOCATION = "/web/assets/imgs/avatars/players/"; |
||
169 | |||
170 | const EDIT_PERMISSION = Permission::EDIT_USER; |
||
171 | const SOFT_DELETE_PERMISSION = Permission::SOFT_DELETE_USER; |
||
172 | const HARD_DELETE_PERMISSION = Permission::HARD_DELETE_USER; |
||
173 | |||
174 | /** |
||
175 | * {@inheritdoc} |
||
176 | */ |
||
177 | protected function assignResult($player) |
||
178 | { |
||
179 | $this->bzid = $player['bzid']; |
||
180 | $this->name = $player['username']; |
||
181 | 44 | $this->alias = $player['alias']; |
|
182 | $this->team = $player['team']; |
||
183 | 44 | $this->status = $player['status']; |
|
184 | 44 | $this->avatar = $player['avatar']; |
|
185 | 44 | $this->country = $player['country']; |
|
186 | 44 | ||
187 | 44 | if (key_exists('activity', $player)) { |
|
188 | 44 | $this->matchActivity = ($player['activity'] != null) ? $player['activity'] : 0.0; |
|
189 | 44 | } |
|
190 | } |
||
191 | 44 | ||
192 | /** |
||
193 | * {@inheritdoc} |
||
194 | 44 | */ |
|
195 | protected function assignLazyResult($player) |
||
196 | { |
||
197 | $this->email = $player['email']; |
||
198 | $this->verified = $player['verified']; |
||
199 | 44 | $this->receives = $player['receives']; |
|
200 | $this->confirmCode = $player['confirm_code']; |
||
201 | 44 | $this->outdated = $player['outdated']; |
|
202 | 44 | $this->description = $player['description']; |
|
203 | 44 | $this->timezone = $player['timezone']; |
|
204 | 44 | $this->joined = TimeDate::fromMysql($player['joined']); |
|
205 | 44 | $this->last_login = TimeDate::fromMysql($player['last_login']); |
|
206 | 44 | $this->last_match = Match::get($player['last_match']); |
|
207 | 44 | $this->admin_notes = $player['admin_notes']; |
|
208 | 44 | $this->ban = Ban::getBan($this->id); |
|
209 | 44 | ||
210 | 44 | $this->cachedMatchSummary = []; |
|
211 | 44 | ||
212 | 44 | $this->updateUserPermissions(); |
|
213 | } |
||
214 | 44 | ||
215 | /** |
||
216 | 44 | * Add a player a new role |
|
217 | 44 | * |
|
218 | * @param Role|int $role_id The role ID to add a player to |
||
219 | * |
||
220 | * @return bool Whether the operation was successful or not |
||
221 | */ |
||
222 | public function addRole($role_id) |
||
223 | { |
||
224 | if ($role_id instanceof Role) { |
||
225 | $role_id = $role_id->getId(); |
||
226 | 44 | } |
|
227 | |||
228 | 44 | $this->lazyLoad(); |
|
229 | 1 | ||
230 | // Make sure the player doesn't already have the role |
||
231 | foreach ($this->roles as $playerRole) { |
||
232 | 44 | if ($playerRole->getId() == $role_id) { |
|
233 | return false; |
||
234 | } |
||
235 | 44 | } |
|
236 | 14 | ||
237 | 14 | $status = $this->modifyRole($role_id, "add"); |
|
238 | $this->refresh(); |
||
239 | |||
240 | return $status; |
||
241 | 44 | } |
|
242 | 44 | ||
243 | /** |
||
244 | 44 | * Get the notes admins have left about a player |
|
245 | * @return string The notes |
||
246 | */ |
||
247 | public function getAdminNotes() |
||
248 | { |
||
249 | $this->lazyLoad(); |
||
250 | |||
251 | return $this->admin_notes; |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * Get the player's BZID |
||
256 | * @return int The BZID |
||
257 | */ |
||
258 | public function getBZID() |
||
259 | { |
||
260 | return $this->bzid; |
||
261 | } |
||
262 | 1 | ||
263 | /** |
||
264 | 1 | * Get the country a player belongs to |
|
265 | * |
||
266 | * @return Country The country belongs to |
||
267 | */ |
||
268 | public function getCountry() |
||
269 | { |
||
270 | return Country::get($this->country); |
||
271 | } |
||
272 | 1 | ||
273 | /** |
||
274 | 1 | * Get the e-mail address of the player |
|
275 | * |
||
276 | * @return string The address |
||
277 | */ |
||
278 | public function getEmailAddress() |
||
284 | |||
285 | /** |
||
286 | * Build a key that we'll use for caching season Elo data in this model |
||
287 | * |
||
288 | * @param string|null $season The season to get |
||
289 | * @param int|null $year The year of the season to get |
||
290 | * |
||
291 | * @return string |
||
292 | */ |
||
293 | private function buildSeasonCacheKey(&$season, &$year) |
||
305 | 5 | ||
306 | 5 | /** |
|
307 | * Get the Elo changes for a player for a given season |
||
308 | * |
||
309 | 5 | * @param string|null $season The season to get |
|
310 | 5 | * @param int|null $year The year of the season to get |
|
311 | * |
||
312 | * @return array |
||
313 | 5 | */ |
|
314 | public function getEloSeasonHistory($season = null, $year = null) |
||
349 | 5 | ||
350 | 5 | /** |
|
351 | * Get the player's Elo for a season. |
||
352 | 5 | * |
|
353 | 4 | * With the default arguments, it will fetch the Elo for the current season. |
|
354 | * |
||
355 | 4 | * @param string|null $season The season we're looking for: winter, spring, summer, or fall |
|
356 | * @param int|null $year The year of the season we're looking for |
||
357 | 5 | * |
|
358 | * @return int The player's Elo |
||
359 | */ |
||
360 | public function getElo($season = null, $year = null) |
||
367 | |||
368 | /** |
||
369 | * Adjust the Elo of a player for the current season based on a Match |
||
370 | * |
||
371 | * **Warning:** If $match is null, the Elo for the player will be modified but the value will not be persisted to |
||
372 | * the database. |
||
373 | * |
||
374 | * @param int $adjust The value to be added to the current ELO (negative to subtract) |
||
375 | * @param Match|null $match The match where this Elo change took place |
||
376 | */ |
||
377 | public function adjustElo($adjust, Match $match = null) |
||
394 | |||
395 | /** |
||
396 | * Returns whether the player has verified their e-mail address |
||
397 | * |
||
398 | * @return bool `true` for verified players |
||
399 | */ |
||
400 | public function isVerified() |
||
406 | 1 | ||
407 | /** |
||
408 | 1 | * Returns the confirmation code for the player's e-mail address verification |
|
409 | * |
||
410 | * @return string The player's confirmation code |
||
411 | */ |
||
412 | public function getConfirmCode() |
||
418 | |||
419 | /** |
||
420 | * Returns what kind of events the player should be e-mailed about |
||
421 | * |
||
422 | * @return string The type of notifications |
||
423 | */ |
||
424 | public function getReceives() |
||
430 | |||
431 | /** |
||
432 | * Finds out whether the specified player wants and can receive an e-mail |
||
433 | * message |
||
434 | * |
||
435 | * @param string $type |
||
436 | * @return bool `true` if the player should be sent an e-mail |
||
437 | */ |
||
438 | public function canReceive($type) |
||
453 | |||
454 | /** |
||
455 | * Find out whether the specified confirmation code is correct |
||
456 | * |
||
457 | * This method protects against timing attacks |
||
458 | * |
||
459 | * @param string $code The confirmation code to check |
||
460 | * @return bool `true` for a correct e-mail verification code |
||
461 | */ |
||
462 | public function isCorrectConfirmCode($code) |
||
472 | |||
473 | /** |
||
474 | * Get the player's sanitized description |
||
475 | * @return string The description |
||
476 | */ |
||
477 | public function getDescription() |
||
483 | |||
484 | /** |
||
485 | * Get the joined date of the player |
||
486 | * @return TimeDate The joined date of the player |
||
487 | */ |
||
488 | public function getJoinedDate() |
||
494 | |||
495 | /** |
||
496 | * Get all of the known IPs used by the player |
||
497 | * |
||
498 | * @return string[][] An array containing IPs and hosts |
||
499 | */ |
||
500 | public function getKnownIPs() |
||
507 | 3 | ||
508 | /** |
||
509 | 3 | * Get the last login for a player |
|
510 | * @return TimeDate The date of the last login |
||
511 | */ |
||
512 | public function getLastLogin() |
||
518 | 1 | ||
519 | /** |
||
520 | 1 | * Get the last match |
|
521 | * @return Match |
||
522 | */ |
||
523 | public function getLastMatch() |
||
529 | |||
530 | /** |
||
531 | * Get all of the callsigns a player has used to log in to the website |
||
532 | * @return string[] An array containing all of the past callsigns recorded for a player |
||
533 | */ |
||
534 | public function getPastCallsigns() |
||
538 | |||
539 | 44 | /** |
|
540 | 44 | * Get the player's team |
|
541 | * @return Team The object representing the team |
||
542 | 44 | */ |
|
543 | 44 | public function getTeam() |
|
547 | |||
548 | /** |
||
549 | * Get the player's timezone PHP identifier (example: "Europe/Paris") |
||
550 | * @return string The timezone |
||
551 | */ |
||
552 | public function getTimezone() |
||
558 | |||
559 | /** |
||
560 | 2 | * Get the roles of the player |
|
561 | * @return Role[] |
||
562 | 2 | */ |
|
563 | public function getRoles() |
||
569 | |||
570 | /** |
||
571 | * Rebuild the list of permissions a user has been granted |
||
572 | */ |
||
573 | private function updateUserPermissions() |
||
582 | |||
583 | /** |
||
584 | * Check if a player has a specific permission |
||
585 | * |
||
586 | * @param string|null $permission The permission to check for |
||
587 | * |
||
588 | * @return bool Whether or not the player has the permission |
||
589 | */ |
||
590 | public function hasPermission($permission) |
||
600 | |||
601 | /** |
||
602 | * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered |
||
603 | * active |
||
604 | * |
||
605 | * @return bool True if the player has been active |
||
606 | */ |
||
607 | public function hasBeenActive() |
||
623 | |||
624 | /** |
||
625 | * Check whether the callsign of the player is outdated |
||
626 | * |
||
627 | * Returns true if this player has probably changed their callsign, making |
||
628 | 23 | * the current username stored in the database obsolete |
|
629 | * |
||
630 | 23 | * @return bool Whether or not the player is disabled |
|
631 | */ |
||
632 | public function isOutdated() |
||
638 | 1 | ||
639 | /** |
||
640 | * Check if a player's account has been disabled |
||
641 | * |
||
642 | 1 | * @return bool Whether or not the player is disabled |
|
643 | */ |
||
644 | public function isDisabled() |
||
648 | |||
649 | /** |
||
650 | * Check if everyone can log in as this user on a test environment |
||
651 | * |
||
652 | * @return bool |
||
653 | */ |
||
654 | public function isTestUser() |
||
658 | |||
659 | /** |
||
660 | * Check if a player is teamless |
||
661 | * |
||
662 | 2 | * @return bool True if the player is teamless |
|
663 | */ |
||
664 | 2 | public function isTeamless() |
|
668 | |||
669 | /** |
||
670 | * Mark a player's account as banned |
||
671 | */ |
||
672 | public function markAsBanned() |
||
680 | |||
681 | /** |
||
682 | * Mark a player's account as unbanned |
||
683 | */ |
||
684 | public function markAsUnbanned() |
||
692 | |||
693 | /** |
||
694 | * Find out if a player is banned |
||
695 | * |
||
696 | * @return bool |
||
697 | */ |
||
698 | public function isBanned() |
||
702 | |||
703 | /** |
||
704 | * Get the ban of the player |
||
705 | * |
||
706 | * This method performs a load of all the lazy parameters of the Player |
||
707 | * |
||
708 | * @return Ban|null The current ban of the player, or null if the player is |
||
709 | * is not banned |
||
710 | */ |
||
711 | public function getBan() |
||
717 | |||
718 | /** |
||
719 | * Remove a player from a role |
||
720 | * |
||
721 | * @param int $role_id The role ID to add or remove |
||
722 | * |
||
723 | * @return bool Whether the operation was successful or not |
||
724 | */ |
||
725 | public function removeRole($role_id) |
||
732 | |||
733 | /** |
||
734 | * Set the player's email address and reset their verification status |
||
735 | * @param string $email The address |
||
736 | */ |
||
737 | public function setEmailAddress($email) |
||
751 | |||
752 | /** |
||
753 | * Set whether the player has verified their e-mail address |
||
754 | * |
||
755 | * @param bool $verified Whether the player is verified or not |
||
756 | * @return self |
||
757 | */ |
||
758 | public function setVerified($verified) |
||
768 | |||
769 | /** |
||
770 | * Generate a new random confirmation token for e-mail address verification |
||
771 | * |
||
772 | * @return self |
||
773 | */ |
||
774 | public function generateNewConfirmCode() |
||
781 | |||
782 | 44 | /** |
|
783 | * Set the confirmation token for e-mail address verification |
||
784 | * |
||
785 | * @param string $code The confirmation code |
||
786 | * @return self |
||
787 | */ |
||
788 | private function setConfirmCode($code) |
||
794 | |||
795 | /** |
||
796 | * Set what kind of events the player should be e-mailed about |
||
797 | * |
||
798 | * @param string $receives The type of notification |
||
799 | * @return self |
||
800 | */ |
||
801 | public function setReceives($receives) |
||
807 | 23 | ||
808 | /** |
||
809 | 23 | * Set whether the callsign of the player is outdated |
|
810 | 23 | * |
|
811 | * @param bool $outdated Whether the callsign is outdated |
||
812 | * @return self |
||
813 | */ |
||
814 | public function setOutdated($outdated) |
||
820 | 14 | ||
821 | /** |
||
822 | * Set the player's description |
||
823 | * @param string $description The description |
||
824 | */ |
||
825 | public function setDescription($description) |
||
829 | |||
830 | /** |
||
831 | * Set the player's timezone |
||
832 | * @param string $timezone The timezone |
||
833 | */ |
||
834 | public function setTimezone($timezone) |
||
838 | |||
839 | /** |
||
840 | * Set the player's team |
||
841 | * @param int $team The team's ID |
||
842 | */ |
||
843 | public function setTeam($team) |
||
847 | |||
848 | /** |
||
849 | * Set the match the player last participated in |
||
850 | * |
||
851 | * @param int $match The match's ID |
||
852 | */ |
||
853 | public function setLastMatch($match) |
||
857 | |||
858 | /** |
||
859 | * Set the player's status |
||
860 | * @param string $status The new status |
||
861 | */ |
||
862 | public function setStatus($status) |
||
866 | |||
867 | /** |
||
868 | * Set the player's admin notes |
||
869 | * @param string $admin_notes The new admin notes |
||
870 | * @return self |
||
871 | */ |
||
872 | 1 | public function setAdminNotes($admin_notes) |
|
876 | |||
877 | /** |
||
878 | * Set the player's country |
||
879 | * @param int $country The ID of the new country |
||
880 | * @return self |
||
881 | */ |
||
882 | public function setCountry($country) |
||
886 | |||
887 | /** |
||
888 | * Updates this player's last login |
||
889 | */ |
||
890 | public function updateLastLogin() |
||
894 | |||
895 | /** |
||
896 | * Get the player's username |
||
897 | * @return string The username |
||
898 | */ |
||
899 | public function getUsername() |
||
903 | |||
904 | /** |
||
905 | * Get the player's username, safe for use in your HTML |
||
906 | * @return string The username |
||
907 | */ |
||
908 | public function getEscapedUsername() |
||
912 | |||
913 | /** |
||
914 | * Alias for Player::setUsername() |
||
915 | * |
||
916 | * @param string $username The new username |
||
917 | * @return self |
||
918 | */ |
||
919 | public function setName($username) |
||
923 | |||
924 | /** |
||
925 | * Mark all the unread messages of a player as read |
||
926 | * |
||
927 | * @return void |
||
928 | */ |
||
929 | public function markMessagesAsRead() |
||
936 | |||
937 | /** |
||
938 | * Set the roles of a user |
||
939 | * |
||
940 | 44 | * @todo Is it worth making this faster? |
|
941 | * @param Role[] $roles The new roles of the user |
||
942 | 44 | * @return self |
|
943 | */ |
||
944 | 44 | public function setRoles($roles) |
|
967 | 2 | ||
968 | /** |
||
969 | * Give or remove a role to/form a player |
||
970 | * |
||
971 | * @param int $role_id The role ID to add or remove |
||
972 | * @param string $action Whether to "add" or "remove" a role for a player |
||
973 | * |
||
974 | * @return bool Whether the operation was successful or not |
||
975 | */ |
||
976 | 1 | private function modifyRole($role_id, $action) |
|
994 | |||
995 | /** |
||
996 | * Given a player's BZID, get a player object |
||
997 | * |
||
998 | 1 | * @param int $bzid The player's BZID |
|
999 | * @return Player |
||
1000 | 1 | */ |
|
1001 | public static function getFromBZID($bzid) |
||
1005 | |||
1006 | /** |
||
1007 | * Get a single player by their username |
||
1008 | * |
||
1009 | * @param string $username The username to look for |
||
1010 | * @return Player |
||
1011 | */ |
||
1012 | public static function getFromUsername($username) |
||
1018 | |||
1019 | /** |
||
1020 | * Get all the players in the database that have an active status |
||
1021 | * @return Player[] An array of player BZIDs |
||
1022 | */ |
||
1023 | public static function getPlayers() |
||
1029 | |||
1030 | /** |
||
1031 | * Show the number of notifications the user hasn't read yet |
||
1032 | * @return int |
||
1033 | */ |
||
1034 | public function countUnreadNotifications() |
||
1038 | |||
1039 | /** |
||
1040 | * Count the number of matches a player has participated in |
||
1041 | * @return int |
||
1042 | */ |
||
1043 | public function getMatchCount() |
||
1054 | |||
1055 | /** |
||
1056 | * Get the (victory/total matches) ratio of the player |
||
1057 | * @return float |
||
1058 | */ |
||
1059 | public function getMatchWinRatio() |
||
1074 | |||
1075 | /** |
||
1076 | * Get the (total caps made by team/total matches) ratio of the player |
||
1077 | * @return float |
||
1078 | */ |
||
1079 | public function getMatchAverageCaps() |
||
1103 | |||
1104 | /** |
||
1105 | * Get the match activity in matches per day for a player |
||
1106 | * |
||
1107 | * @return float |
||
1108 | */ |
||
1109 | public function getMatchActivity() |
||
1129 | |||
1130 | /** |
||
1131 | * Return an array of matches this player participated in per month. |
||
1132 | * |
||
1133 | * ``` |
||
1134 | * ['yyyy-mm'] = <number of matches> |
||
1135 | * ``` |
||
1136 | * |
||
1137 | * @param TimeDate|string $timePeriod |
||
1138 | * |
||
1139 | * @return int[] |
||
1140 | 14 | */ |
|
1141 | public function getMatchSummary($timePeriod = '1 year ago') |
||
1156 | 2 | ||
1157 | 2 | /** |
|
1158 | * Show the number of messages the user hasn't read yet |
||
1159 | * @return int |
||
1160 | */ |
||
1161 | public function countUnreadMessages() |
||
1167 | |||
1168 | /** |
||
1169 | * Routine maintenance for a player when they participate in a match. |
||
1170 | * |
||
1171 | * This function updates the last match played, changes the ELO, and creates a historic ELO change. |
||
1172 | 44 | * |
|
1173 | * @param Match $match |
||
1174 | * @param int $eloDiff |
||
1175 | 44 | */ |
|
1176 | public function setMatchParticipation(Match $match, $eloDiff) |
||
1184 | |||
1185 | 44 | /** |
|
1186 | * Get all of the members belonging to a team |
||
1187 | * @param int $teamID The ID of the team to fetch the members of |
||
1188 | * @return Player[] An array of Player objects of the team members |
||
1189 | */ |
||
1190 | public static function getTeamMembers($teamID) |
||
1196 | |||
1197 | /** |
||
1198 | * {@inheritdoc} |
||
1199 | */ |
||
1200 | public static function getActiveStatuses() |
||
1204 | |||
1205 | /** |
||
1206 | * {@inheritdoc} |
||
1207 | 44 | */ |
|
1208 | public static function getEagerColumns($prefix = null) |
||
1223 | |||
1224 | /** |
||
1225 | * {@inheritdoc} |
||
1226 | */ |
||
1227 | public static function getLazyColumns($prefix = null) |
||
1245 | 44 | ||
1246 | 44 | /** |
|
1247 | * Get a query builder for players |
||
1248 | 44 | * @return PlayerQueryBuilder |
|
1249 | 44 | */ |
|
1250 | 44 | public static function getQueryBuilder() |
|
1262 | 44 | ||
1263 | 44 | /** |
|
1264 | 44 | * Enter a new player to the database |
|
1265 | * @param int $bzid The player's bzid |
||
1266 | 44 | * @param string $username The player's username |
|
1267 | * @param int $team The player's team |
||
1268 | * @param string $status The player's status |
||
1269 | * @param int $role_id The player's role when they are first created |
||
1270 | * @param string $avatar The player's profile avatar |
||
1271 | * @param string $description The player's profile description |
||
1272 | * @param int $country The player's country |
||
1273 | * @param string $timezone The player's timezone |
||
1274 | * @param string|\TimeDate $joined The date the player joined |
||
1275 | * @param string|\TimeDate $last_login The timestamp of the player's last login |
||
1276 | * @return Player An object representing the player that was just entered |
||
1277 | */ |
||
1278 | 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") |
||
1304 | |||
1305 | /** |
||
1306 | * Determine if a player exists in the database |
||
1307 | * @param int $bzid The player's bzid |
||
1308 | * @return bool Whether the player exists in the database |
||
1309 | */ |
||
1310 | public static function playerBZIDExists($bzid) |
||
1314 | |||
1315 | /** |
||
1316 | * Change a player's callsign and add it to the database if it does not |
||
1317 | * exist as a past callsign |
||
1318 | * |
||
1319 | * @param string $username The new username of the player |
||
1320 | * @return self |
||
1321 | */ |
||
1322 | public function setUsername($username) |
||
1353 | |||
1354 | /** |
||
1355 | * Alphabetical order function for use in usort (case-insensitive) |
||
1356 | * @return Closure The sort function |
||
1357 | */ |
||
1358 | public static function getAlphabeticalSort() |
||
1364 | |||
1365 | 1 | /** |
|
1366 | * {@inheritdoc} |
||
1367 | * @todo Add a constraint that does this automatically |
||
1368 | */ |
||
1369 | public function wipe() |
||
1375 | 1 | ||
1376 | /** |
||
1377 | 1 | * Find whether the player can delete a model |
|
1378 | * |
||
1379 | * @param PermissionModel $model The model that will be seen |
||
1380 | * @param bool $showDeleted Whether to show deleted models to admins |
||
1381 | * @return bool |
||
1382 | */ |
||
1383 | public function canSee($model, $showDeleted = false) |
||
1387 | |||
1388 | 1 | /** |
|
1389 | * Find whether the player can delete a model |
||
1390 | * |
||
1391 | * @param PermissionModel $model The model that will be deleted |
||
1392 | * @param bool $hard Whether to check for hard-delete perms, as opposed |
||
1393 | * to soft-delete ones |
||
1394 | * @return bool |
||
1395 | */ |
||
1396 | public function canDelete($model, $hard = false) |
||
1404 | |||
1405 | /** |
||
1406 | * Find whether the player can create a model |
||
1407 | * |
||
1408 | * @param string $modelName The PHP class identifier of the model type |
||
1409 | * @return bool |
||
1410 | */ |
||
1411 | public function canCreate($modelName) |
||
1415 | |||
1416 | /** |
||
1417 | * Find whether the player can edit a model |
||
1418 | * |
||
1419 | * @param PermissionModel $model The model which will be edited |
||
1420 | * @return bool |
||
1421 | */ |
||
1422 | public function canEdit($model) |
||
1426 | } |
||
1427 |
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..