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 | 72 | protected function assignResult($player) |
|
178 | { |
||
179 | 72 | $this->bzid = $player['bzid']; |
|
180 | 72 | $this->name = $player['username']; |
|
181 | 72 | $this->alias = $player['alias']; |
|
182 | 72 | $this->team = $player['team']; |
|
183 | 72 | $this->status = $player['status']; |
|
184 | 72 | $this->avatar = $player['avatar']; |
|
185 | 72 | $this->country = $player['country']; |
|
186 | |||
187 | 72 | if (key_exists('activity', $player)) { |
|
188 | $this->matchActivity = ($player['activity'] != null) ? $player['activity'] : 0.0; |
||
189 | } |
||
190 | 72 | } |
|
191 | |||
192 | /** |
||
193 | * {@inheritdoc} |
||
194 | */ |
||
195 | 72 | protected function assignLazyResult($player) |
|
214 | |||
215 | /** |
||
216 | * Add a player a new role |
||
217 | * |
||
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 | 72 | public function addRole($role_id) |
|
223 | { |
||
224 | 72 | if ($role_id instanceof Role) { |
|
225 | 1 | $role_id = $role_id->getId(); |
|
226 | } |
||
227 | |||
228 | 72 | $this->lazyLoad(); |
|
229 | |||
230 | // Make sure the player doesn't already have the role |
||
231 | 72 | foreach ($this->roles as $playerRole) { |
|
232 | 14 | if ($playerRole->getId() == $role_id) { |
|
233 | 14 | return false; |
|
234 | } |
||
235 | } |
||
236 | |||
237 | 72 | $status = $this->modifyRole($role_id, "add"); |
|
238 | 72 | $this->refresh(); |
|
239 | |||
240 | 72 | return $status; |
|
241 | } |
||
242 | |||
243 | /** |
||
244 | * Get the notes admins have left about a player |
||
245 | * @return string The notes |
||
246 | */ |
||
247 | public function getAdminNotes() |
||
253 | |||
254 | /** |
||
255 | * Get the player's BZID |
||
256 | * @return int The BZID |
||
257 | */ |
||
258 | 22 | public function getBZID() |
|
262 | |||
263 | /** |
||
264 | * Get the country a player belongs to |
||
265 | * |
||
266 | * @return Country The country belongs to |
||
267 | */ |
||
268 | 1 | public function getCountry() |
|
272 | |||
273 | /** |
||
274 | * 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 | 29 | private function buildSeasonKey(&$season, &$year) |
|
305 | |||
306 | /** |
||
307 | * Build a key to use for caching season Elo data in this model from a timestamp |
||
308 | * |
||
309 | * @param DateTime $timestamp |
||
310 | * |
||
311 | * @return string |
||
312 | */ |
||
313 | 2 | private function buildSeasonKeyFromTimestamp(\DateTime $timestamp) |
|
319 | |||
320 | /** |
||
321 | * Remove all Elo data for this model for matches occurring after the given match (inclusive) |
||
322 | * |
||
323 | * This function will not remove the Elo data for this match from the database. Ideally, this function should only |
||
324 | * be called during Elo recalculation for this match. |
||
325 | * |
||
326 | * @internal |
||
327 | * |
||
328 | * @param Match $match |
||
329 | * |
||
330 | * @see Match::recalculateElo() |
||
331 | */ |
||
332 | 2 | public function invalidateMatchFromCache(Match $match) |
|
354 | |||
355 | /** |
||
356 | * Get the Elo changes for a player for a given season |
||
357 | * |
||
358 | * @param string|null $season The season to get |
||
359 | * @param int|null $year The year of the season to get |
||
360 | * |
||
361 | * @return array |
||
362 | */ |
||
363 | 29 | public function getEloSeasonHistory($season = null, $year = null) |
|
390 | |||
391 | /** |
||
392 | * Get the player's Elo for a season. |
||
393 | * |
||
394 | * With the default arguments, it will fetch the Elo for the current season. |
||
395 | * |
||
396 | * @param string|null $season The season we're looking for: winter, spring, summer, or fall |
||
397 | * @param int|null $year The year of the season we're looking for |
||
398 | * |
||
399 | * @return int The player's Elo |
||
400 | */ |
||
401 | 29 | public function getElo($season = null, $year = null) |
|
421 | |||
422 | /** |
||
423 | * Adjust the Elo of a player for the current season based on a Match |
||
424 | * |
||
425 | * **Warning:** If $match is null, the Elo for the player will be modified but the value will not be persisted to |
||
426 | * the database. |
||
427 | * |
||
428 | * @param int $adjust The value to be added to the current ELO (negative to subtract) |
||
429 | * @param Match|null $match The match where this Elo change took place |
||
430 | */ |
||
431 | 29 | public function adjustElo($adjust, Match $match = null) |
|
448 | |||
449 | /** |
||
450 | * Returns whether the player has verified their e-mail address |
||
451 | * |
||
452 | * @return bool `true` for verified players |
||
453 | */ |
||
454 | public function isVerified() |
||
460 | |||
461 | /** |
||
462 | * Returns the confirmation code for the player's e-mail address verification |
||
463 | * |
||
464 | * @return string The player's confirmation code |
||
465 | */ |
||
466 | public function getConfirmCode() |
||
472 | |||
473 | /** |
||
474 | * Returns what kind of events the player should be e-mailed about |
||
475 | * |
||
476 | * @return string The type of notifications |
||
477 | */ |
||
478 | public function getReceives() |
||
484 | |||
485 | /** |
||
486 | * Finds out whether the specified player wants and can receive an e-mail |
||
487 | * message |
||
488 | * |
||
489 | * @param string $type |
||
490 | * @return bool `true` if the player should be sent an e-mail |
||
491 | */ |
||
492 | 1 | public function canReceive($type) |
|
507 | |||
508 | /** |
||
509 | * Find out whether the specified confirmation code is correct |
||
510 | * |
||
511 | * This method protects against timing attacks |
||
512 | * |
||
513 | * @param string $code The confirmation code to check |
||
514 | * @return bool `true` for a correct e-mail verification code |
||
515 | */ |
||
516 | public function isCorrectConfirmCode($code) |
||
526 | |||
527 | /** |
||
528 | * Get the player's sanitized description |
||
529 | * @return string The description |
||
530 | */ |
||
531 | public function getDescription() |
||
537 | |||
538 | /** |
||
539 | * Get the joined date of the player |
||
540 | * @return TimeDate The joined date of the player |
||
541 | */ |
||
542 | public function getJoinedDate() |
||
548 | |||
549 | /** |
||
550 | * Get all of the known IPs used by the player |
||
551 | * |
||
552 | * @return string[][] An array containing IPs and hosts |
||
553 | */ |
||
554 | public function getKnownIPs() |
||
561 | |||
562 | /** |
||
563 | * Get the last login for a player |
||
564 | * @return TimeDate The date of the last login |
||
565 | */ |
||
566 | public function getLastLogin() |
||
572 | |||
573 | /** |
||
574 | * Get the last match |
||
575 | * @return Match |
||
576 | */ |
||
577 | public function getLastMatch() |
||
583 | |||
584 | /** |
||
585 | * Get all of the callsigns a player has used to log in to the website |
||
586 | * @return string[] An array containing all of the past callsigns recorded for a player |
||
587 | */ |
||
588 | public function getPastCallsigns() |
||
592 | |||
593 | /** |
||
594 | * Get the player's team |
||
595 | * @return Team The object representing the team |
||
596 | */ |
||
597 | 23 | public function getTeam() |
|
601 | |||
602 | /** |
||
603 | * Get the player's timezone PHP identifier (example: "Europe/Paris") |
||
604 | * @return string The timezone |
||
605 | */ |
||
606 | 1 | public function getTimezone() |
|
612 | |||
613 | /** |
||
614 | * Get the roles of the player |
||
615 | * @return Role[] |
||
616 | */ |
||
617 | public function getRoles() |
||
623 | |||
624 | /** |
||
625 | * Rebuild the list of permissions a user has been granted |
||
626 | */ |
||
627 | 72 | private function updateUserPermissions() |
|
636 | |||
637 | /** |
||
638 | * Check if a player has a specific permission |
||
639 | * |
||
640 | * @param string|null $permission The permission to check for |
||
641 | * |
||
642 | * @return bool Whether or not the player has the permission |
||
643 | */ |
||
644 | 2 | public function hasPermission($permission) |
|
654 | |||
655 | /** |
||
656 | * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered |
||
657 | * active |
||
658 | * |
||
659 | * @return bool True if the player has been active |
||
660 | */ |
||
661 | public function hasBeenActive() |
||
677 | |||
678 | /** |
||
679 | * Check whether the callsign of the player is outdated |
||
680 | * |
||
681 | * Returns true if this player has probably changed their callsign, making |
||
682 | * the current username stored in the database obsolete |
||
683 | * |
||
684 | * @return bool Whether or not the player is disabled |
||
685 | */ |
||
686 | public function isOutdated() |
||
692 | |||
693 | /** |
||
694 | * Check if a player's account has been disabled |
||
695 | * |
||
696 | * @return bool Whether or not the player is disabled |
||
697 | */ |
||
698 | public function isDisabled() |
||
702 | |||
703 | /** |
||
704 | * Check if everyone can log in as this user on a test environment |
||
705 | * |
||
706 | * @return bool |
||
707 | */ |
||
708 | 1 | public function isTestUser() |
|
712 | |||
713 | /** |
||
714 | * Check if a player is teamless |
||
715 | * |
||
716 | * @return bool True if the player is teamless |
||
717 | */ |
||
718 | 51 | public function isTeamless() |
|
722 | |||
723 | /** |
||
724 | * Mark a player's account as banned |
||
725 | */ |
||
726 | 1 | public function markAsBanned() |
|
734 | |||
735 | /** |
||
736 | * Mark a player's account as unbanned |
||
737 | */ |
||
738 | public function markAsUnbanned() |
||
746 | |||
747 | /** |
||
748 | * Find out if a player is banned |
||
749 | * |
||
750 | * @return bool |
||
751 | */ |
||
752 | 2 | public function isBanned() |
|
756 | |||
757 | /** |
||
758 | * Get the ban of the player |
||
759 | * |
||
760 | * This method performs a load of all the lazy parameters of the Player |
||
761 | * |
||
762 | * @return Ban|null The current ban of the player, or null if the player is |
||
763 | * is not banned |
||
764 | */ |
||
765 | public function getBan() |
||
771 | |||
772 | /** |
||
773 | * Remove a player from a role |
||
774 | * |
||
775 | * @param int $role_id The role ID to add or remove |
||
776 | * |
||
777 | * @return bool Whether the operation was successful or not |
||
778 | */ |
||
779 | public function removeRole($role_id) |
||
786 | |||
787 | /** |
||
788 | * Set the player's email address and reset their verification status |
||
789 | * @param string $email The address |
||
790 | */ |
||
791 | public function setEmailAddress($email) |
||
805 | |||
806 | /** |
||
807 | * Set whether the player has verified their e-mail address |
||
808 | * |
||
809 | * @param bool $verified Whether the player is verified or not |
||
810 | * @return self |
||
811 | */ |
||
812 | public function setVerified($verified) |
||
822 | |||
823 | /** |
||
824 | * Generate a new random confirmation token for e-mail address verification |
||
825 | * |
||
826 | * @return self |
||
827 | */ |
||
828 | public function generateNewConfirmCode() |
||
835 | |||
836 | /** |
||
837 | * Set the confirmation token for e-mail address verification |
||
838 | * |
||
839 | * @param string $code The confirmation code |
||
840 | * @return self |
||
841 | */ |
||
842 | private function setConfirmCode($code) |
||
848 | |||
849 | /** |
||
850 | * Set what kind of events the player should be e-mailed about |
||
851 | * |
||
852 | * @param string $receives The type of notification |
||
853 | * @return self |
||
854 | */ |
||
855 | public function setReceives($receives) |
||
861 | |||
862 | /** |
||
863 | * Set whether the callsign of the player is outdated |
||
864 | * |
||
865 | * @param bool $outdated Whether the callsign is outdated |
||
866 | * @return self |
||
867 | */ |
||
868 | 72 | public function setOutdated($outdated) |
|
874 | |||
875 | /** |
||
876 | * Set the player's description |
||
877 | * @param string $description The description |
||
878 | */ |
||
879 | public function setDescription($description) |
||
883 | |||
884 | /** |
||
885 | * Set the player's timezone |
||
886 | * @param string $timezone The timezone |
||
887 | */ |
||
888 | public function setTimezone($timezone) |
||
892 | |||
893 | /** |
||
894 | * Set the player's team |
||
895 | * @param int $team The team's ID |
||
896 | */ |
||
897 | 51 | public function setTeam($team) |
|
901 | |||
902 | /** |
||
903 | * Set the match the player last participated in |
||
904 | * |
||
905 | * @param int $match The match's ID |
||
906 | */ |
||
907 | 28 | public function setLastMatch($match) |
|
911 | |||
912 | /** |
||
913 | * Set the player's status |
||
914 | * @param string $status The new status |
||
915 | */ |
||
916 | public function setStatus($status) |
||
920 | |||
921 | /** |
||
922 | * Set the player's admin notes |
||
923 | * @param string $admin_notes The new admin notes |
||
924 | * @return self |
||
925 | */ |
||
926 | public function setAdminNotes($admin_notes) |
||
930 | |||
931 | /** |
||
932 | * Set the player's country |
||
933 | * @param int $country The ID of the new country |
||
934 | * @return self |
||
935 | */ |
||
936 | public function setCountry($country) |
||
940 | |||
941 | /** |
||
942 | * Updates this player's last login |
||
943 | */ |
||
944 | public function updateLastLogin() |
||
948 | |||
949 | /** |
||
950 | * Get the player's username |
||
951 | * @return string The username |
||
952 | */ |
||
953 | 1 | public function getUsername() |
|
957 | |||
958 | /** |
||
959 | * Get the player's username, safe for use in your HTML |
||
960 | * @return string The username |
||
961 | */ |
||
962 | 1 | public function getEscapedUsername() |
|
966 | |||
967 | /** |
||
968 | * Alias for Player::setUsername() |
||
969 | * |
||
970 | * @param string $username The new username |
||
971 | * @return self |
||
972 | */ |
||
973 | public function setName($username) |
||
977 | |||
978 | /** |
||
979 | * Mark all the unread messages of a player as read |
||
980 | * |
||
981 | * @return void |
||
982 | */ |
||
983 | public function markMessagesAsRead() |
||
990 | |||
991 | /** |
||
992 | * Set the roles of a user |
||
993 | * |
||
994 | * @todo Is it worth making this faster? |
||
995 | * @param Role[] $roles The new roles of the user |
||
996 | * @return self |
||
997 | */ |
||
998 | public function setRoles($roles) |
||
1021 | |||
1022 | /** |
||
1023 | * Give or remove a role to/form a player |
||
1024 | * |
||
1025 | * @param int $role_id The role ID to add or remove |
||
1026 | * @param string $action Whether to "add" or "remove" a role for a player |
||
1027 | * |
||
1028 | * @return bool Whether the operation was successful or not |
||
1029 | */ |
||
1030 | 72 | private function modifyRole($role_id, $action) |
|
1048 | |||
1049 | /** |
||
1050 | * Given a player's BZID, get a player object |
||
1051 | * |
||
1052 | * @param int $bzid The player's BZID |
||
1053 | * @return Player |
||
1054 | */ |
||
1055 | 23 | public static function getFromBZID($bzid) |
|
1059 | |||
1060 | /** |
||
1061 | * Get a single player by their username |
||
1062 | * |
||
1063 | * @param string $username The username to look for |
||
1064 | * @return Player |
||
1065 | */ |
||
1066 | 1 | public static function getFromUsername($username) |
|
1072 | |||
1073 | /** |
||
1074 | * Get all the players in the database that have an active status |
||
1075 | * @return Player[] An array of player BZIDs |
||
1076 | */ |
||
1077 | public static function getPlayers() |
||
1083 | |||
1084 | /** |
||
1085 | * Show the number of notifications the user hasn't read yet |
||
1086 | * @return int |
||
1087 | */ |
||
1088 | 1 | public function countUnreadNotifications() |
|
1092 | |||
1093 | /** |
||
1094 | * Count the number of matches a player has participated in |
||
1095 | * @return int |
||
1096 | */ |
||
1097 | public function getMatchCount() |
||
1108 | |||
1109 | /** |
||
1110 | * Get the (victory/total matches) ratio of the player |
||
1111 | * @return float |
||
1112 | */ |
||
1113 | public function getMatchWinRatio() |
||
1128 | |||
1129 | /** |
||
1130 | * Get the (total caps made by team/total matches) ratio of the player |
||
1131 | * @return float |
||
1132 | */ |
||
1133 | public function getMatchAverageCaps() |
||
1157 | |||
1158 | /** |
||
1159 | * Get the match activity in matches per day for a player |
||
1160 | * |
||
1161 | * @return float |
||
1162 | */ |
||
1163 | public function getMatchActivity() |
||
1183 | |||
1184 | /** |
||
1185 | * Return an array of matches this player participated in per month. |
||
1186 | * |
||
1187 | * ``` |
||
1188 | * ['yyyy-mm'] = <number of matches> |
||
1189 | * ``` |
||
1190 | * |
||
1191 | * @param TimeDate|string $timePeriod |
||
1192 | * |
||
1193 | * @return int[] |
||
1194 | */ |
||
1195 | public function getMatchSummary($timePeriod = '1 year ago') |
||
1210 | |||
1211 | /** |
||
1212 | * Show the number of messages the user hasn't read yet |
||
1213 | * @return int |
||
1214 | */ |
||
1215 | 1 | public function countUnreadMessages() |
|
1221 | |||
1222 | /** |
||
1223 | * Get all of the members belonging to a team |
||
1224 | * @param int $teamID The ID of the team to fetch the members of |
||
1225 | * @return Player[] An array of Player objects of the team members |
||
1226 | */ |
||
1227 | 2 | public static function getTeamMembers($teamID) |
|
1233 | |||
1234 | /** |
||
1235 | * {@inheritdoc} |
||
1236 | */ |
||
1237 | 1 | public static function getActiveStatuses() |
|
1241 | |||
1242 | /** |
||
1243 | * {@inheritdoc} |
||
1244 | */ |
||
1245 | 72 | public static function getEagerColumns($prefix = null) |
|
1260 | |||
1261 | /** |
||
1262 | * {@inheritdoc} |
||
1263 | */ |
||
1264 | 72 | public static function getLazyColumns($prefix = null) |
|
1282 | |||
1283 | /** |
||
1284 | * Get a query builder for players |
||
1285 | * @return PlayerQueryBuilder |
||
1286 | */ |
||
1287 | public static function getQueryBuilder() |
||
1299 | |||
1300 | /** |
||
1301 | * Enter a new player to the database |
||
1302 | * @param int $bzid The player's bzid |
||
1303 | * @param string $username The player's username |
||
1304 | * @param int $team The player's team |
||
1305 | * @param string $status The player's status |
||
1306 | * @param int $role_id The player's role when they are first created |
||
1307 | * @param string $avatar The player's profile avatar |
||
1308 | * @param string $description The player's profile description |
||
1309 | * @param int $country The player's country |
||
1310 | * @param string $timezone The player's timezone |
||
1311 | * @param string|\TimeDate $joined The date the player joined |
||
1312 | * @param string|\TimeDate $last_login The timestamp of the player's last login |
||
1313 | * @return Player An object representing the player that was just entered |
||
1314 | */ |
||
1315 | 72 | 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") |
|
1341 | |||
1342 | /** |
||
1343 | * Determine if a player exists in the database |
||
1344 | * @param int $bzid The player's bzid |
||
1345 | * @return bool Whether the player exists in the database |
||
1346 | */ |
||
1347 | public static function playerBZIDExists($bzid) |
||
1351 | |||
1352 | /** |
||
1353 | * Change a player's callsign and add it to the database if it does not |
||
1354 | * exist as a past callsign |
||
1355 | * |
||
1356 | * @param string $username The new username of the player |
||
1357 | * @return self |
||
1358 | */ |
||
1359 | 72 | public function setUsername($username) |
|
1390 | |||
1391 | /** |
||
1392 | * Alphabetical order function for use in usort (case-insensitive) |
||
1393 | * @return Closure The sort function |
||
1394 | */ |
||
1395 | public static function getAlphabeticalSort() |
||
1401 | |||
1402 | /** |
||
1403 | * {@inheritdoc} |
||
1404 | * @todo Add a constraint that does this automatically |
||
1405 | */ |
||
1406 | 72 | public function wipe() |
|
1412 | |||
1413 | /** |
||
1414 | * Find whether the player can delete a model |
||
1415 | * |
||
1416 | * @param PermissionModel $model The model that will be seen |
||
1417 | * @param bool $showDeleted Whether to show deleted models to admins |
||
1418 | * @return bool |
||
1419 | */ |
||
1420 | 1 | public function canSee($model, $showDeleted = false) |
|
1424 | |||
1425 | /** |
||
1426 | * Find whether the player can delete a model |
||
1427 | * |
||
1428 | * @param PermissionModel $model The model that will be deleted |
||
1429 | * @param bool $hard Whether to check for hard-delete perms, as opposed |
||
1430 | * to soft-delete ones |
||
1431 | * @return bool |
||
1432 | */ |
||
1433 | 1 | public function canDelete($model, $hard = false) |
|
1441 | |||
1442 | /** |
||
1443 | * Find whether the player can create a model |
||
1444 | * |
||
1445 | * @param string $modelName The PHP class identifier of the model type |
||
1446 | * @return bool |
||
1447 | */ |
||
1448 | 1 | public function canCreate($modelName) |
|
1452 | |||
1453 | /** |
||
1454 | * Find whether the player can edit a model |
||
1455 | * |
||
1456 | * @param PermissionModel $model The model which will be edited |
||
1457 | * @return bool |
||
1458 | */ |
||
1459 | 1 | public function canEdit($model) |
|
1463 | } |
||
1464 |
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..