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 | /** |
||
| 156 | * The player's current Elo |
||
| 157 | * |
||
| 158 | * @var int |
||
| 159 | */ |
||
| 160 | private $elo; |
||
| 161 | |||
| 162 | private $matchActivity; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * The name of the database table used for queries |
||
| 166 | */ |
||
| 167 | const TABLE = "players"; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * The location where avatars will be stored |
||
| 171 | */ |
||
| 172 | const AVATAR_LOCATION = "/web/assets/imgs/avatars/players/"; |
||
| 173 | |||
| 174 | const EDIT_PERMISSION = Permission::EDIT_USER; |
||
| 175 | const SOFT_DELETE_PERMISSION = Permission::SOFT_DELETE_USER; |
||
| 176 | const HARD_DELETE_PERMISSION = Permission::HARD_DELETE_USER; |
||
| 177 | |||
| 178 | /** |
||
| 179 | * {@inheritdoc} |
||
| 180 | */ |
||
| 181 | 44 | protected function assignResult($player) |
|
| 195 | |||
| 196 | /** |
||
| 197 | * {@inheritdoc} |
||
| 198 | */ |
||
| 199 | 44 | protected function assignLazyResult($player) |
|
| 218 | |||
| 219 | /** |
||
| 220 | * Add a player a new role |
||
| 221 | * |
||
| 222 | * @param Role|int $role_id The role ID to add a player to |
||
| 223 | * |
||
| 224 | * @return bool Whether the operation was successful or not |
||
| 225 | */ |
||
| 226 | 44 | public function addRole($role_id) |
|
| 246 | |||
| 247 | /** |
||
| 248 | * Get the notes admins have left about a player |
||
| 249 | * @return string The notes |
||
| 250 | */ |
||
| 251 | public function getAdminNotes() |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Get the player's BZID |
||
| 260 | * @return int The BZID |
||
| 261 | */ |
||
| 262 | 1 | public function getBZID() |
|
| 266 | |||
| 267 | /** |
||
| 268 | * Get the country a player belongs to |
||
| 269 | * |
||
| 270 | * @return Country The country belongs to |
||
| 271 | */ |
||
| 272 | 1 | public function getCountry() |
|
| 276 | |||
| 277 | /** |
||
| 278 | * Get the e-mail address of the player |
||
| 279 | * |
||
| 280 | * @return string The address |
||
| 281 | */ |
||
| 282 | public function getEmailAddress() |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Get the player's Elo for a season. |
||
| 291 | * |
||
| 292 | * With the default arguments, it will fetch the Elo for the current season. |
||
| 293 | * |
||
| 294 | * @param string|null $season The season we're looking for: winter, spring, summer, or fall |
||
| 295 | * @param int|null $year The year of the season we're looking for |
||
| 296 | * |
||
| 297 | * @return int The player's Elo |
||
| 298 | */ |
||
| 299 | 5 | public function getElo($season = null, $year = null) |
|
| 333 | |||
| 334 | /** |
||
| 335 | * Adjust the Elo of a player for the current season based on a Match |
||
| 336 | * |
||
| 337 | * **Warning:** If $match is null, the Elo for the player will be modified but the value will not be persisted to |
||
| 338 | * the database. |
||
| 339 | * |
||
| 340 | * @param int $adjust The value to be added to the current ELO (negative to subtract) |
||
| 341 | * @param Match|null $match The match where this Elo change took place |
||
| 342 | */ |
||
| 343 | 5 | public function adjustElo($adjust, Match $match = null) |
|
| 354 | |||
| 355 | /** |
||
| 356 | * Returns whether the player has verified their e-mail address |
||
| 357 | * |
||
| 358 | * @return bool `true` for verified players |
||
| 359 | */ |
||
| 360 | public function isVerified() |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Returns the confirmation code for the player's e-mail address verification |
||
| 369 | * |
||
| 370 | * @return string The player's confirmation code |
||
| 371 | */ |
||
| 372 | public function getConfirmCode() |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Returns what kind of events the player should be e-mailed about |
||
| 381 | * |
||
| 382 | * @return string The type of notifications |
||
| 383 | */ |
||
| 384 | public function getReceives() |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Finds out whether the specified player wants and can receive an e-mail |
||
| 393 | * message |
||
| 394 | * |
||
| 395 | * @param string $type |
||
| 396 | * @return bool `true` if the player should be sent an e-mail |
||
| 397 | */ |
||
| 398 | 1 | public function canReceive($type) |
|
| 413 | |||
| 414 | /** |
||
| 415 | * Find out whether the specified confirmation code is correct |
||
| 416 | * |
||
| 417 | * This method protects against timing attacks |
||
| 418 | * |
||
| 419 | * @param string $code The confirmation code to check |
||
| 420 | * @return bool `true` for a correct e-mail verification code |
||
| 421 | */ |
||
| 422 | public function isCorrectConfirmCode($code) |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Get the player's sanitized description |
||
| 435 | * @return string The description |
||
| 436 | */ |
||
| 437 | public function getDescription() |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Get the joined date of the player |
||
| 446 | * @return TimeDate The joined date of the player |
||
| 447 | */ |
||
| 448 | public function getJoinedDate() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Get all of the known IPs used by the player |
||
| 457 | * |
||
| 458 | * @return string[][] An array containing IPs and hosts |
||
| 459 | */ |
||
| 460 | public function getKnownIPs() |
||
| 467 | |||
| 468 | /** |
||
| 469 | * Get the last login for a player |
||
| 470 | * @return TimeDate The date of the last login |
||
| 471 | */ |
||
| 472 | public function getLastLogin() |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Get the last match |
||
| 481 | * @return Match |
||
| 482 | */ |
||
| 483 | public function getLastMatch() |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Get all of the callsigns a player has used to log in to the website |
||
| 492 | * @return string[] An array containing all of the past callsigns recorded for a player |
||
| 493 | */ |
||
| 494 | public function getPastCallsigns() |
||
| 498 | |||
| 499 | /** |
||
| 500 | * Get the player's team |
||
| 501 | * @return Team The object representing the team |
||
| 502 | */ |
||
| 503 | 3 | public function getTeam() |
|
| 507 | |||
| 508 | /** |
||
| 509 | * Get the player's timezone PHP identifier (example: "Europe/Paris") |
||
| 510 | * @return string The timezone |
||
| 511 | */ |
||
| 512 | 1 | public function getTimezone() |
|
| 518 | |||
| 519 | /** |
||
| 520 | * Get the roles of the player |
||
| 521 | * @return Role[] |
||
| 522 | */ |
||
| 523 | public function getRoles() |
||
| 529 | |||
| 530 | /** |
||
| 531 | * Rebuild the list of permissions a user has been granted |
||
| 532 | */ |
||
| 533 | 44 | private function updateUserPermissions() |
|
| 542 | |||
| 543 | /** |
||
| 544 | * Check if a player has a specific permission |
||
| 545 | * |
||
| 546 | * @param string|null $permission The permission to check for |
||
| 547 | * |
||
| 548 | * @return bool Whether or not the player has the permission |
||
| 549 | */ |
||
| 550 | 2 | public function hasPermission($permission) |
|
| 560 | |||
| 561 | /** |
||
| 562 | * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered |
||
| 563 | * active |
||
| 564 | * |
||
| 565 | * @return bool True if the player has been active |
||
| 566 | */ |
||
| 567 | public function hasBeenActive() |
||
| 583 | |||
| 584 | /** |
||
| 585 | * Check whether the callsign of the player is outdated |
||
| 586 | * |
||
| 587 | * Returns true if this player has probably changed their callsign, making |
||
| 588 | * the current username stored in the database obsolete |
||
| 589 | * |
||
| 590 | * @return bool Whether or not the player is disabled |
||
| 591 | */ |
||
| 592 | public function isOutdated() |
||
| 598 | |||
| 599 | /** |
||
| 600 | * Check if a player's account has been disabled |
||
| 601 | * |
||
| 602 | * @return bool Whether or not the player is disabled |
||
| 603 | */ |
||
| 604 | public function isDisabled() |
||
| 608 | |||
| 609 | /** |
||
| 610 | * Check if everyone can log in as this user on a test environment |
||
| 611 | * |
||
| 612 | * @return bool |
||
| 613 | */ |
||
| 614 | 1 | public function isTestUser() |
|
| 618 | |||
| 619 | /** |
||
| 620 | * Check if a player is teamless |
||
| 621 | * |
||
| 622 | * @return bool True if the player is teamless |
||
| 623 | */ |
||
| 624 | 23 | public function isTeamless() |
|
| 628 | |||
| 629 | /** |
||
| 630 | * Mark a player's account as banned |
||
| 631 | */ |
||
| 632 | 1 | public function markAsBanned() |
|
| 640 | |||
| 641 | /** |
||
| 642 | * Mark a player's account as unbanned |
||
| 643 | */ |
||
| 644 | public function markAsUnbanned() |
||
| 652 | |||
| 653 | /** |
||
| 654 | * Find out if a player is banned |
||
| 655 | * |
||
| 656 | * @return bool |
||
| 657 | */ |
||
| 658 | 2 | public function isBanned() |
|
| 662 | |||
| 663 | /** |
||
| 664 | * Get the ban of the player |
||
| 665 | * |
||
| 666 | * This method performs a load of all the lazy parameters of the Player |
||
| 667 | * |
||
| 668 | * @return Ban|null The current ban of the player, or null if the player is |
||
| 669 | * is not banned |
||
| 670 | */ |
||
| 671 | public function getBan() |
||
| 677 | |||
| 678 | /** |
||
| 679 | * Remove a player from a role |
||
| 680 | * |
||
| 681 | * @param int $role_id The role ID to add or remove |
||
| 682 | * |
||
| 683 | * @return bool Whether the operation was successful or not |
||
| 684 | */ |
||
| 685 | public function removeRole($role_id) |
||
| 692 | |||
| 693 | /** |
||
| 694 | * Set the player's email address and reset their verification status |
||
| 695 | * @param string $email The address |
||
| 696 | */ |
||
| 697 | public function setEmailAddress($email) |
||
| 711 | |||
| 712 | /** |
||
| 713 | * Set whether the player has verified their e-mail address |
||
| 714 | * |
||
| 715 | * @param bool $verified Whether the player is verified or not |
||
| 716 | * @return self |
||
| 717 | */ |
||
| 718 | public function setVerified($verified) |
||
| 728 | |||
| 729 | /** |
||
| 730 | * Generate a new random confirmation token for e-mail address verification |
||
| 731 | * |
||
| 732 | * @return self |
||
| 733 | */ |
||
| 734 | public function generateNewConfirmCode() |
||
| 741 | |||
| 742 | /** |
||
| 743 | * Set the confirmation token for e-mail address verification |
||
| 744 | * |
||
| 745 | * @param string $code The confirmation code |
||
| 746 | * @return self |
||
| 747 | */ |
||
| 748 | private function setConfirmCode($code) |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Set what kind of events the player should be e-mailed about |
||
| 757 | * |
||
| 758 | * @param string $receives The type of notification |
||
| 759 | * @return self |
||
| 760 | */ |
||
| 761 | public function setReceives($receives) |
||
| 767 | |||
| 768 | /** |
||
| 769 | * Set whether the callsign of the player is outdated |
||
| 770 | * |
||
| 771 | * @param bool $outdated Whether the callsign is outdated |
||
| 772 | * @return self |
||
| 773 | */ |
||
| 774 | 44 | public function setOutdated($outdated) |
|
| 780 | |||
| 781 | /** |
||
| 782 | * Set the player's description |
||
| 783 | * @param string $description The description |
||
| 784 | */ |
||
| 785 | public function setDescription($description) |
||
| 789 | |||
| 790 | /** |
||
| 791 | * Set the player's timezone |
||
| 792 | * @param string $timezone The timezone |
||
| 793 | */ |
||
| 794 | public function setTimezone($timezone) |
||
| 798 | |||
| 799 | /** |
||
| 800 | * Set the player's team |
||
| 801 | * @param int $team The team's ID |
||
| 802 | */ |
||
| 803 | 23 | public function setTeam($team) |
|
| 807 | |||
| 808 | /** |
||
| 809 | * Set the match the player last participated in |
||
| 810 | * |
||
| 811 | * @param int $match The match's ID |
||
| 812 | */ |
||
| 813 | 14 | public function setLastMatch($match) |
|
| 817 | |||
| 818 | /** |
||
| 819 | * Set the player's status |
||
| 820 | * @param string $status The new status |
||
| 821 | */ |
||
| 822 | public function setStatus($status) |
||
| 826 | |||
| 827 | /** |
||
| 828 | * Set the player's admin notes |
||
| 829 | * @param string $admin_notes The new admin notes |
||
| 830 | * @return self |
||
| 831 | */ |
||
| 832 | public function setAdminNotes($admin_notes) |
||
| 836 | |||
| 837 | /** |
||
| 838 | * Set the player's country |
||
| 839 | * @param int $country The ID of the new country |
||
| 840 | * @return self |
||
| 841 | */ |
||
| 842 | public function setCountry($country) |
||
| 846 | |||
| 847 | /** |
||
| 848 | * Updates this player's last login |
||
| 849 | */ |
||
| 850 | public function updateLastLogin() |
||
| 854 | |||
| 855 | /** |
||
| 856 | * Get the player's username |
||
| 857 | * @return string The username |
||
| 858 | */ |
||
| 859 | 1 | public function getUsername() |
|
| 863 | |||
| 864 | /** |
||
| 865 | * Get the player's username, safe for use in your HTML |
||
| 866 | * @return string The username |
||
| 867 | */ |
||
| 868 | 1 | public function getEscapedUsername() |
|
| 872 | |||
| 873 | /** |
||
| 874 | * Alias for Player::setUsername() |
||
| 875 | * |
||
| 876 | * @param string $username The new username |
||
| 877 | * @return self |
||
| 878 | */ |
||
| 879 | public function setName($username) |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Mark all the unread messages of a player as read |
||
| 886 | * |
||
| 887 | * @return void |
||
| 888 | */ |
||
| 889 | public function markMessagesAsRead() |
||
| 896 | |||
| 897 | /** |
||
| 898 | * Set the roles of a user |
||
| 899 | * |
||
| 900 | * @todo Is it worth making this faster? |
||
| 901 | * @param Role[] $roles The new roles of the user |
||
| 902 | * @return self |
||
| 903 | */ |
||
| 904 | public function setRoles($roles) |
||
| 927 | |||
| 928 | /** |
||
| 929 | * Give or remove a role to/form a player |
||
| 930 | * |
||
| 931 | * @param int $role_id The role ID to add or remove |
||
| 932 | * @param string $action Whether to "add" or "remove" a role for a player |
||
| 933 | * |
||
| 934 | * @return bool Whether the operation was successful or not |
||
| 935 | */ |
||
| 936 | 44 | private function modifyRole($role_id, $action) |
|
| 954 | |||
| 955 | /** |
||
| 956 | * Given a player's BZID, get a player object |
||
| 957 | * |
||
| 958 | * @param int $bzid The player's BZID |
||
| 959 | * @return Player |
||
| 960 | */ |
||
| 961 | 2 | public static function getFromBZID($bzid) |
|
| 965 | |||
| 966 | /** |
||
| 967 | * Get a single player by their username |
||
| 968 | * |
||
| 969 | * @param string $username The username to look for |
||
| 970 | * @return Player |
||
| 971 | */ |
||
| 972 | 1 | public static function getFromUsername($username) |
|
| 978 | |||
| 979 | /** |
||
| 980 | * Get all the players in the database that have an active status |
||
| 981 | * @return Player[] An array of player BZIDs |
||
| 982 | */ |
||
| 983 | public static function getPlayers() |
||
| 989 | |||
| 990 | /** |
||
| 991 | * Show the number of notifications the user hasn't read yet |
||
| 992 | * @return int |
||
| 993 | */ |
||
| 994 | 1 | public function countUnreadNotifications() |
|
| 998 | |||
| 999 | /** |
||
| 1000 | * Count the number of matches a player has participated in |
||
| 1001 | * @return int |
||
| 1002 | */ |
||
| 1003 | public function getMatchCount() |
||
| 1014 | |||
| 1015 | /** |
||
| 1016 | * Get the (victory/total matches) ratio of the player |
||
| 1017 | * @return float |
||
| 1018 | */ |
||
| 1019 | public function getMatchWinRatio() |
||
| 1034 | |||
| 1035 | /** |
||
| 1036 | * Get the (total caps made by team/total matches) ratio of the player |
||
| 1037 | * @return float |
||
| 1038 | */ |
||
| 1039 | public function getMatchAverageCaps() |
||
| 1063 | |||
| 1064 | /** |
||
| 1065 | * Get the match activity in matches per day for a player |
||
| 1066 | * |
||
| 1067 | * @return float |
||
| 1068 | */ |
||
| 1069 | public function getMatchActivity() |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * Return an array of matches this player participated in per month. |
||
| 1092 | * |
||
| 1093 | * ``` |
||
| 1094 | * ['yyyy-mm'] = <number of matches> |
||
| 1095 | * ``` |
||
| 1096 | * |
||
| 1097 | * @param TimeDate|string $timePeriod |
||
| 1098 | * |
||
| 1099 | * @return int[] |
||
| 1100 | */ |
||
| 1101 | public function getMatchSummary($timePeriod = '1 year ago') |
||
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Show the number of messages the user hasn't read yet |
||
| 1119 | * @return int |
||
| 1120 | */ |
||
| 1121 | 1 | public function countUnreadMessages() |
|
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Routine maintenance for a player when they participate in a match. |
||
| 1130 | * |
||
| 1131 | * This function updates the last match played, changes the ELO, and creates a historic ELO change. |
||
| 1132 | * |
||
| 1133 | * @param Match $match |
||
| 1134 | * @param int $eloDiff |
||
| 1135 | */ |
||
| 1136 | 14 | public function setMatchParticipation(Match $match, $eloDiff) |
|
| 1144 | |||
| 1145 | /** |
||
| 1146 | * Get all of the members belonging to a team |
||
| 1147 | * @param int $teamID The ID of the team to fetch the members of |
||
| 1148 | * @return Player[] An array of Player objects of the team members |
||
| 1149 | */ |
||
| 1150 | 2 | public static function getTeamMembers($teamID) |
|
| 1156 | |||
| 1157 | /** |
||
| 1158 | * {@inheritdoc} |
||
| 1159 | */ |
||
| 1160 | 1 | public static function getActiveStatuses() |
|
| 1164 | |||
| 1165 | /** |
||
| 1166 | * {@inheritdoc} |
||
| 1167 | */ |
||
| 1168 | 44 | public static function getEagerColumns($prefix = null) |
|
| 1183 | |||
| 1184 | /** |
||
| 1185 | * {@inheritdoc} |
||
| 1186 | */ |
||
| 1187 | 44 | public static function getLazyColumns($prefix = null) |
|
| 1205 | |||
| 1206 | /** |
||
| 1207 | * Get a query builder for players |
||
| 1208 | * @return PlayerQueryBuilder |
||
| 1209 | */ |
||
| 1210 | public static function getQueryBuilder() |
||
| 1222 | |||
| 1223 | /** |
||
| 1224 | * Enter a new player to the database |
||
| 1225 | * @param int $bzid The player's bzid |
||
| 1226 | * @param string $username The player's username |
||
| 1227 | * @param int $team The player's team |
||
| 1228 | * @param string $status The player's status |
||
| 1229 | * @param int $role_id The player's role when they are first created |
||
| 1230 | * @param string $avatar The player's profile avatar |
||
| 1231 | * @param string $description The player's profile description |
||
| 1232 | * @param int $country The player's country |
||
| 1233 | * @param string $timezone The player's timezone |
||
| 1234 | * @param string|\TimeDate $joined The date the player joined |
||
| 1235 | * @param string|\TimeDate $last_login The timestamp of the player's last login |
||
| 1236 | * @return Player An object representing the player that was just entered |
||
| 1237 | */ |
||
| 1238 | 44 | 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") |
|
| 1264 | |||
| 1265 | /** |
||
| 1266 | * Determine if a player exists in the database |
||
| 1267 | * @param int $bzid The player's bzid |
||
| 1268 | * @return bool Whether the player exists in the database |
||
| 1269 | */ |
||
| 1270 | public static function playerBZIDExists($bzid) |
||
| 1274 | |||
| 1275 | /** |
||
| 1276 | * Change a player's callsign and add it to the database if it does not |
||
| 1277 | * exist as a past callsign |
||
| 1278 | * |
||
| 1279 | * @param string $username The new username of the player |
||
| 1280 | * @return self |
||
| 1281 | */ |
||
| 1282 | 44 | public function setUsername($username) |
|
| 1313 | |||
| 1314 | /** |
||
| 1315 | * Alphabetical order function for use in usort (case-insensitive) |
||
| 1316 | * @return Closure The sort function |
||
| 1317 | */ |
||
| 1318 | public static function getAlphabeticalSort() |
||
| 1324 | |||
| 1325 | /** |
||
| 1326 | * {@inheritdoc} |
||
| 1327 | * @todo Add a constraint that does this automatically |
||
| 1328 | */ |
||
| 1329 | 44 | public function wipe() |
|
| 1335 | |||
| 1336 | /** |
||
| 1337 | * Find whether the player can delete a model |
||
| 1338 | * |
||
| 1339 | * @param PermissionModel $model The model that will be seen |
||
| 1340 | * @param bool $showDeleted Whether to show deleted models to admins |
||
| 1341 | * @return bool |
||
| 1342 | */ |
||
| 1343 | 1 | public function canSee($model, $showDeleted = false) |
|
| 1347 | |||
| 1348 | /** |
||
| 1349 | * Find whether the player can delete a model |
||
| 1350 | * |
||
| 1351 | * @param PermissionModel $model The model that will be deleted |
||
| 1352 | * @param bool $hard Whether to check for hard-delete perms, as opposed |
||
| 1353 | * to soft-delete ones |
||
| 1354 | * @return bool |
||
| 1355 | */ |
||
| 1356 | 1 | public function canDelete($model, $hard = false) |
|
| 1364 | |||
| 1365 | /** |
||
| 1366 | * Find whether the player can create a model |
||
| 1367 | * |
||
| 1368 | * @param string $modelName The PHP class identifier of the model type |
||
| 1369 | * @return bool |
||
| 1370 | */ |
||
| 1371 | 1 | public function canCreate($modelName) |
|
| 1375 | |||
| 1376 | /** |
||
| 1377 | * Find whether the player can edit a model |
||
| 1378 | * |
||
| 1379 | * @param PermissionModel $model The model which will be edited |
||
| 1380 | * @return bool |
||
| 1381 | */ |
||
| 1382 | 1 | public function canEdit($model) |
|
| 1386 | } |
||
| 1387 |
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..