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 |
||
| 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 | protected function assignResult($player) |
||
| 195 | |||
| 196 | /** |
||
| 197 | * {@inheritdoc} |
||
| 198 | */ |
||
| 199 | 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 | 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 | public function getBZID() |
||
| 266 | |||
| 267 | /** |
||
| 268 | * Get the country a player belongs to |
||
| 269 | * |
||
| 270 | * @return Country The country belongs to |
||
| 271 | */ |
||
| 272 | 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 or -1 if the player hasn't played in the specified season. |
||
| 298 | */ |
||
| 299 | public function getElo($season = null, $year = null) |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Returns whether the player has verified their e-mail address |
||
| 336 | * |
||
| 337 | * @return bool `true` for verified players |
||
| 338 | */ |
||
| 339 | public function isVerified() |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Returns the confirmation code for the player's e-mail address verification |
||
| 348 | * |
||
| 349 | * @return string The player's confirmation code |
||
| 350 | */ |
||
| 351 | public function getConfirmCode() |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Returns what kind of events the player should be e-mailed about |
||
| 360 | * |
||
| 361 | * @return string The type of notifications |
||
| 362 | */ |
||
| 363 | public function getReceives() |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Finds out whether the specified player wants and can receive an e-mail |
||
| 372 | * message |
||
| 373 | * |
||
| 374 | * @param string $type |
||
| 375 | * @return bool `true` if the player should be sent an e-mail |
||
| 376 | */ |
||
| 377 | public function canReceive($type) |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Find out whether the specified confirmation code is correct |
||
| 395 | * |
||
| 396 | * This method protects against timing attacks |
||
| 397 | * |
||
| 398 | * @param string $code The confirmation code to check |
||
| 399 | * @return bool `true` for a correct e-mail verification code |
||
| 400 | */ |
||
| 401 | public function isCorrectConfirmCode($code) |
||
| 411 | |||
| 412 | /** |
||
| 413 | * Get the player's sanitized description |
||
| 414 | * @return string The description |
||
| 415 | */ |
||
| 416 | public function getDescription() |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Get the joined date of the player |
||
| 425 | * @return TimeDate The joined date of the player |
||
| 426 | */ |
||
| 427 | public function getJoinedDate() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Get all of the known IPs used by the player |
||
| 436 | * |
||
| 437 | * @return string[][] An array containing IPs and hosts |
||
| 438 | */ |
||
| 439 | public function getKnownIPs() |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Get the last login for a player |
||
| 449 | * @return TimeDate The date of the last login |
||
| 450 | */ |
||
| 451 | public function getLastLogin() |
||
| 457 | |||
| 458 | /** |
||
| 459 | * Get the last match |
||
| 460 | * @return Match |
||
| 461 | */ |
||
| 462 | public function getLastMatch() |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Get all of the callsigns a player has used to log in to the website |
||
| 471 | * @return string[] An array containing all of the past callsigns recorded for a player |
||
| 472 | */ |
||
| 473 | public function getPastCallsigns() |
||
| 477 | |||
| 478 | /** |
||
| 479 | * Get the player's team |
||
| 480 | * @return Team The object representing the team |
||
| 481 | */ |
||
| 482 | public function getTeam() |
||
| 486 | |||
| 487 | /** |
||
| 488 | * Get the player's timezone PHP identifier (example: "Europe/Paris") |
||
| 489 | * @return string The timezone |
||
| 490 | */ |
||
| 491 | public function getTimezone() |
||
| 497 | |||
| 498 | /** |
||
| 499 | * Get the roles of the player |
||
| 500 | * @return Role[] |
||
| 501 | */ |
||
| 502 | public function getRoles() |
||
| 508 | |||
| 509 | /** |
||
| 510 | * Rebuild the list of permissions a user has been granted |
||
| 511 | */ |
||
| 512 | private function updateUserPermissions() |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Check if a player has a specific permission |
||
| 524 | * |
||
| 525 | * @param string|null $permission The permission to check for |
||
| 526 | * |
||
| 527 | * @return bool Whether or not the player has the permission |
||
| 528 | */ |
||
| 529 | public function hasPermission($permission) |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered |
||
| 542 | * active |
||
| 543 | * |
||
| 544 | * @return bool True if the player has been active |
||
| 545 | */ |
||
| 546 | public function hasBeenActive() |
||
| 562 | |||
| 563 | /** |
||
| 564 | * Check whether the callsign of the player is outdated |
||
| 565 | * |
||
| 566 | * Returns true if this player has probably changed their callsign, making |
||
| 567 | * the current username stored in the database obsolete |
||
| 568 | * |
||
| 569 | * @return bool Whether or not the player is disabled |
||
| 570 | */ |
||
| 571 | public function isOutdated() |
||
| 577 | |||
| 578 | /** |
||
| 579 | * Check if a player's account has been disabled |
||
| 580 | * |
||
| 581 | * @return bool Whether or not the player is disabled |
||
| 582 | */ |
||
| 583 | public function isDisabled() |
||
| 587 | |||
| 588 | /** |
||
| 589 | * Check if everyone can log in as this user on a test environment |
||
| 590 | * |
||
| 591 | * @return bool |
||
| 592 | */ |
||
| 593 | public function isTestUser() |
||
| 597 | |||
| 598 | /** |
||
| 599 | * Check if a player is teamless |
||
| 600 | * |
||
| 601 | * @return bool True if the player is teamless |
||
| 602 | */ |
||
| 603 | public function isTeamless() |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Mark a player's account as banned |
||
| 610 | */ |
||
| 611 | public function markAsBanned() |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Mark a player's account as unbanned |
||
| 622 | */ |
||
| 623 | public function markAsUnbanned() |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Find out if a player is banned |
||
| 634 | * |
||
| 635 | * @return bool |
||
| 636 | */ |
||
| 637 | public function isBanned() |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Get the ban of the player |
||
| 644 | * |
||
| 645 | * This method performs a load of all the lazy parameters of the Player |
||
| 646 | * |
||
| 647 | * @return Ban|null The current ban of the player, or null if the player is |
||
| 648 | * is not banned |
||
| 649 | */ |
||
| 650 | public function getBan() |
||
| 656 | |||
| 657 | /** |
||
| 658 | * Remove a player from a role |
||
| 659 | * |
||
| 660 | * @param int $role_id The role ID to add or remove |
||
| 661 | * |
||
| 662 | * @return bool Whether the operation was successful or not |
||
| 663 | */ |
||
| 664 | public function removeRole($role_id) |
||
| 671 | |||
| 672 | /** |
||
| 673 | * Set the player's email address and reset their verification status |
||
| 674 | * @param string $email The address |
||
| 675 | */ |
||
| 676 | public function setEmailAddress($email) |
||
| 690 | |||
| 691 | /** |
||
| 692 | * Set whether the player has verified their e-mail address |
||
| 693 | * |
||
| 694 | * @param bool $verified Whether the player is verified or not |
||
| 695 | * @return self |
||
| 696 | */ |
||
| 697 | public function setVerified($verified) |
||
| 707 | |||
| 708 | /** |
||
| 709 | * Generate a new random confirmation token for e-mail address verification |
||
| 710 | * |
||
| 711 | * @return self |
||
| 712 | */ |
||
| 713 | public function generateNewConfirmCode() |
||
| 720 | |||
| 721 | /** |
||
| 722 | * Set the confirmation token for e-mail address verification |
||
| 723 | * |
||
| 724 | * @param string $code The confirmation code |
||
| 725 | * @return self |
||
| 726 | */ |
||
| 727 | private function setConfirmCode($code) |
||
| 733 | |||
| 734 | /** |
||
| 735 | * Set what kind of events the player should be e-mailed about |
||
| 736 | * |
||
| 737 | * @param string $receives The type of notification |
||
| 738 | * @return self |
||
| 739 | */ |
||
| 740 | public function setReceives($receives) |
||
| 746 | |||
| 747 | /** |
||
| 748 | * Set whether the callsign of the player is outdated |
||
| 749 | * |
||
| 750 | * @param bool $outdated Whether the callsign is outdated |
||
| 751 | * @return self |
||
| 752 | */ |
||
| 753 | public function setOutdated($outdated) |
||
| 759 | |||
| 760 | /** |
||
| 761 | * Set the player's description |
||
| 762 | * @param string $description The description |
||
| 763 | */ |
||
| 764 | public function setDescription($description) |
||
| 768 | |||
| 769 | /** |
||
| 770 | * Set the player's timezone |
||
| 771 | * @param string $timezone The timezone |
||
| 772 | */ |
||
| 773 | public function setTimezone($timezone) |
||
| 777 | |||
| 778 | /** |
||
| 779 | * Set the player's team |
||
| 780 | * @param int $team The team's ID |
||
| 781 | */ |
||
| 782 | public function setTeam($team) |
||
| 786 | |||
| 787 | /** |
||
| 788 | * Set the match the player last participated in |
||
| 789 | * |
||
| 790 | * @param int $match The match's ID |
||
| 791 | */ |
||
| 792 | public function setLastMatch($match) |
||
| 796 | |||
| 797 | /** |
||
| 798 | * Set the player's status |
||
| 799 | * @param string $status The new status |
||
| 800 | */ |
||
| 801 | public function setStatus($status) |
||
| 805 | |||
| 806 | /** |
||
| 807 | * Set the player's admin notes |
||
| 808 | * @param string $admin_notes The new admin notes |
||
| 809 | * @return self |
||
| 810 | */ |
||
| 811 | public function setAdminNotes($admin_notes) |
||
| 815 | |||
| 816 | /** |
||
| 817 | * Set the player's country |
||
| 818 | * @param int $country The ID of the new country |
||
| 819 | * @return self |
||
| 820 | */ |
||
| 821 | public function setCountry($country) |
||
| 825 | |||
| 826 | /** |
||
| 827 | * Updates this player's last login |
||
| 828 | */ |
||
| 829 | public function updateLastLogin() |
||
| 833 | |||
| 834 | /** |
||
| 835 | * Get the player's username |
||
| 836 | * @return string The username |
||
| 837 | */ |
||
| 838 | public function getUsername() |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Get the player's username, safe for use in your HTML |
||
| 845 | * @return string The username |
||
| 846 | */ |
||
| 847 | public function getEscapedUsername() |
||
| 851 | |||
| 852 | /** |
||
| 853 | * Alias for Player::setUsername() |
||
| 854 | * |
||
| 855 | * @param string $username The new username |
||
| 856 | * @return self |
||
| 857 | */ |
||
| 858 | public function setName($username) |
||
| 862 | |||
| 863 | /** |
||
| 864 | * Mark all the unread messages of a player as read |
||
| 865 | * |
||
| 866 | * @return void |
||
| 867 | */ |
||
| 868 | public function markMessagesAsRead() |
||
| 875 | |||
| 876 | /** |
||
| 877 | * Set the roles of a user |
||
| 878 | * |
||
| 879 | * @todo Is it worth making this faster? |
||
| 880 | * @param Role[] $roles The new roles of the user |
||
| 881 | * @return self |
||
| 882 | */ |
||
| 883 | public function setRoles($roles) |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Give or remove a role to/form a player |
||
| 909 | * |
||
| 910 | * @param int $role_id The role ID to add or remove |
||
| 911 | * @param string $action Whether to "add" or "remove" a role for a player |
||
| 912 | * |
||
| 913 | * @return bool Whether the operation was successful or not |
||
| 914 | */ |
||
| 915 | private function modifyRole($role_id, $action) |
||
| 933 | |||
| 934 | /** |
||
| 935 | * Given a player's BZID, get a player object |
||
| 936 | * |
||
| 937 | * @param int $bzid The player's BZID |
||
| 938 | * @return Player |
||
| 939 | */ |
||
| 940 | public static function getFromBZID($bzid) |
||
| 944 | |||
| 945 | /** |
||
| 946 | * Get a single player by their username |
||
| 947 | * |
||
| 948 | * @param string $username The username to look for |
||
| 949 | * @return Player |
||
| 950 | */ |
||
| 951 | public static function getFromUsername($username) |
||
| 957 | |||
| 958 | /** |
||
| 959 | * Get all the players in the database that have an active status |
||
| 960 | * @return Player[] An array of player BZIDs |
||
| 961 | */ |
||
| 962 | public static function getPlayers() |
||
| 968 | |||
| 969 | /** |
||
| 970 | * Show the number of notifications the user hasn't read yet |
||
| 971 | * @return int |
||
| 972 | */ |
||
| 973 | public function countUnreadNotifications() |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Count the number of matches a player has participated in |
||
| 980 | * @return int |
||
| 981 | */ |
||
| 982 | public function getMatchCount() |
||
| 993 | |||
| 994 | /** |
||
| 995 | * Get the (victory/total matches) ratio of the player |
||
| 996 | * @return float |
||
| 997 | */ |
||
| 998 | public function getMatchWinRatio() |
||
| 1013 | |||
| 1014 | /** |
||
| 1015 | * Get the (total caps made by team/total matches) ratio of the player |
||
| 1016 | * @return float |
||
| 1017 | */ |
||
| 1018 | public function getMatchAverageCaps() |
||
| 1042 | |||
| 1043 | /** |
||
| 1044 | * Get the match activity in matches per day for a player |
||
| 1045 | * |
||
| 1046 | * @return float |
||
| 1047 | */ |
||
| 1048 | public function getMatchActivity() |
||
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Return an array of matches this player participated in per month. |
||
| 1071 | * |
||
| 1072 | * ``` |
||
| 1073 | * ['yyyy-mm'] = <number of matches> |
||
| 1074 | * ``` |
||
| 1075 | * |
||
| 1076 | * @param TimeDate|string $timePeriod |
||
| 1077 | * |
||
| 1078 | * @return int[] |
||
| 1079 | */ |
||
| 1080 | public function getMatchSummary($timePeriod = '1 year ago') |
||
| 1095 | |||
| 1096 | /** |
||
| 1097 | * Show the number of messages the user hasn't read yet |
||
| 1098 | * @return int |
||
| 1099 | */ |
||
| 1100 | public function countUnreadMessages() |
||
| 1106 | |||
| 1107 | /** |
||
| 1108 | * Get all of the members belonging to a team |
||
| 1109 | * @param int $teamID The ID of the team to fetch the members of |
||
| 1110 | * @return Player[] An array of Player objects of the team members |
||
| 1111 | */ |
||
| 1112 | public static function getTeamMembers($teamID) |
||
| 1118 | |||
| 1119 | /** |
||
| 1120 | * {@inheritdoc} |
||
| 1121 | */ |
||
| 1122 | public static function getActiveStatuses() |
||
| 1126 | |||
| 1127 | /** |
||
| 1128 | * {@inheritdoc} |
||
| 1129 | */ |
||
| 1130 | public static function getEagerColumns($prefix = null) |
||
| 1145 | |||
| 1146 | /** |
||
| 1147 | * {@inheritdoc} |
||
| 1148 | */ |
||
| 1149 | public static function getLazyColumns($prefix = null) |
||
| 1167 | |||
| 1168 | /** |
||
| 1169 | * Get a query builder for players |
||
| 1170 | * @return PlayerQueryBuilder |
||
| 1171 | */ |
||
| 1172 | public static function getQueryBuilder() |
||
| 1184 | |||
| 1185 | /** |
||
| 1186 | * Enter a new player to the database |
||
| 1187 | * @param int $bzid The player's bzid |
||
| 1188 | * @param string $username The player's username |
||
| 1189 | * @param int $team The player's team |
||
| 1190 | * @param string $status The player's status |
||
| 1191 | * @param int $role_id The player's role when they are first created |
||
| 1192 | * @param string $avatar The player's profile avatar |
||
| 1193 | * @param string $description The player's profile description |
||
| 1194 | * @param int $country The player's country |
||
| 1195 | * @param string $timezone The player's timezone |
||
| 1196 | * @param string|\TimeDate $joined The date the player joined |
||
| 1197 | * @param string|\TimeDate $last_login The timestamp of the player's last login |
||
| 1198 | * @return Player An object representing the player that was just entered |
||
| 1199 | */ |
||
| 1200 | 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") |
||
| 1226 | |||
| 1227 | /** |
||
| 1228 | * Determine if a player exists in the database |
||
| 1229 | * @param int $bzid The player's bzid |
||
| 1230 | * @return bool Whether the player exists in the database |
||
| 1231 | */ |
||
| 1232 | public static function playerBZIDExists($bzid) |
||
| 1236 | |||
| 1237 | /** |
||
| 1238 | * Change a player's callsign and add it to the database if it does not |
||
| 1239 | * exist as a past callsign |
||
| 1240 | * |
||
| 1241 | * @param string $username The new username of the player |
||
| 1242 | * @return self |
||
| 1243 | */ |
||
| 1244 | public function setUsername($username) |
||
| 1275 | |||
| 1276 | /** |
||
| 1277 | * Alphabetical order function for use in usort (case-insensitive) |
||
| 1278 | * @return Closure The sort function |
||
| 1279 | */ |
||
| 1280 | public static function getAlphabeticalSort() |
||
| 1286 | |||
| 1287 | /** |
||
| 1288 | * {@inheritdoc} |
||
| 1289 | * @todo Add a constraint that does this automatically |
||
| 1290 | */ |
||
| 1291 | public function wipe() |
||
| 1297 | |||
| 1298 | /** |
||
| 1299 | * Find whether the player can delete a model |
||
| 1300 | * |
||
| 1301 | * @param PermissionModel $model The model that will be seen |
||
| 1302 | * @param bool $showDeleted Whether to show deleted models to admins |
||
| 1303 | * @return bool |
||
| 1304 | */ |
||
| 1305 | public function canSee($model, $showDeleted = false) |
||
| 1309 | |||
| 1310 | /** |
||
| 1311 | * Find whether the player can delete a model |
||
| 1312 | * |
||
| 1313 | * @param PermissionModel $model The model that will be deleted |
||
| 1314 | * @param bool $hard Whether to check for hard-delete perms, as opposed |
||
| 1315 | * to soft-delete ones |
||
| 1316 | * @return bool |
||
| 1317 | */ |
||
| 1318 | public function canDelete($model, $hard = false) |
||
| 1326 | |||
| 1327 | /** |
||
| 1328 | * Find whether the player can create a model |
||
| 1329 | * |
||
| 1330 | * @param string $modelName The PHP class identifier of the model type |
||
| 1331 | * @return bool |
||
| 1332 | */ |
||
| 1333 | public function canCreate($modelName) |
||
| 1337 | |||
| 1338 | /** |
||
| 1339 | * Find whether the player can edit a model |
||
| 1340 | * |
||
| 1341 | * @param PermissionModel $model The model which will be edited |
||
| 1342 | * @return bool |
||
| 1343 | */ |
||
| 1344 | public function canEdit($model) |
||
| 1348 | } |
||
| 1349 |
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..