class Team extends AvatarModel implements TeamInterface, DuplexUrlInterface

A league team

Constants

TABLE

The name of the database table used for queries

AVATAR_LOCATION

The location where avatars will be stored

CREATE_PERMISSION

EDIT_PERMISSION

SOFT_DELETE_PERMISSION

HARD_DELETE_PERMISSION

Properties

static Match[]|null $cachedMatches A list of cached matches to calculate team activity

Methods

bool|null
addMember(int $id)

Adds a new member to the team

changeElo(int $adjust)

Increase or decrease the ELO of the team

setElo(int $elo)

Change the ELO of the team

changeMatchCount(int $adjust, string $type)

Increment the team's match count

decrementMatchCount(string $type)

Decrement the team's match count by one

float
getActivity()

Get the activity of the team

getCreationDate()

Get the creation date of the team

string
getDescription()

Get the description of the team

int
getElo()

Get the current elo of the team

getLeader()

Get the leader of the team

Match[]
getMatches(string $matchType = 'all', int $count = 5, int $page = 1)

Get the matches this team has participated in

int
getMatchesDraw()

Get the number of matches that resulted as a draw

int
getMatchesLost()

Get the number of matches that the team has lost

string
getMatchesURL()

Get the URL that points to the team's list of matches

int
getMatchesWon()

Get the number of matches that the team has won

Player[]
getMembers()

Get the members on the team

string
getName()

Get the name of the team

string
getEscapedName()

Get the name of the team, safe for use in your HTML

int
getNumMembers()

Get the number of members on the team

int
getNumTotalMatches()

Get the total number of matches this team has played

int
getRankValue()

Get the rank category a team belongs too based on their ELO

string
getRankImageLiteral()

Get the HTML for an image with the rank symbol

incrementMatchCount(string $type)

Increment the team's match count by one

bool
isMember(int $playerID)

Check if a player is part of this team

void
removeMember(int $id)

Removes a member from the team

void
setDescription(string $description)

Update the description of the team

setStatus(string $newStatus)

Change the status of the team

setLeader(int $leader)

Change the leader of the team

bool
isLastMatch(int|Match $match)

Find if a specific match is the team's last one

void
delete()

Delete the object

static Team
createTeam(string $name, int $leader, string $avatar, string $description, string $status = 'closed', string|TimeDate $created = 'now')

Create a new team

static Team[]
getTeams()

Get all the teams in the database that are not disabled or deleted

static Team
getFromName(string $name)

Get a single team by its name

static Closure
getAlphabeticalSort()

Alphabetical order function for use in usort (case-insensitive)

static string[]
getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

static QueryBuilder
getQueryBuilder()

Get a query builder for teams

Details

at line line 145
bool|null addMember(int $id)

Adds a new member to the team

Parameters

int $id The id of the player to add to the team

Return Value

bool|null True if both the player was added to the team AND the team member count was incremented

at line line 162
changeElo(int $adjust)

Increase or decrease the ELO of the team

Parameters

int $adjust The value to be added to the current ELO (negative to substract)

at line line 173
setElo(int $elo)

Change the ELO of the team

Parameters

int $elo The new team ELO

at line line 184
changeMatchCount(int $adjust, string $type)

Increment the team's match count

Parameters

int $adjust The number to add to the current matches number (negative to substract)
string $type The match count that should be changed. Can be 'win', 'draw' or 'loss'

at line line 211
decrementMatchCount(string $type)

Decrement the team's match count by one

Parameters

string $type The type of the match. Can be 'win', 'draw' or 'loss'

at line line 221
float getActivity()

Get the activity of the team

Return Value

float The team's activity

at line line 249
TimeDate getCreationDate()

Get the creation date of the team

Return Value

TimeDate The creation date of the team

at line line 259
string getDescription()

Get the description of the team

Return Value

string The description of the team

at line line 269
int getElo()

Get the current elo of the team

Return Value

int The elo of the team

at line line 279
Player getLeader()

Get the leader of the team

Return Value

Player The object representing the team leader

at line line 293
Match[] getMatches(string $matchType = 'all', int $count = 5, int $page = 1)

Get the matches this team has participated in

Parameters

string $matchType The filter for match types: "all", "wins", "losses", or "draws"
int $count The amount of matches to be retrieved
int $page The number of the page to return

Return Value

Match[] The array of match IDs this team has participated in

at line line 308
int getMatchesDraw()

Get the number of matches that resulted as a draw

Return Value

int The number of matches, respectively

at line line 318
int getMatchesLost()

Get the number of matches that the team has lost

Return Value

int The number of matches, respectively

at line line 328
string getMatchesURL()

Get the URL that points to the team's list of matches

Return Value

string The team's list of matches

at line line 338
int getMatchesWon()

Get the number of matches that the team has won

Return Value

int The number of matches, respectively

at line line 348
Player[] getMembers()

Get the members on the team

Return Value

Player[] The members on the team

at line line 376
string getName()

Get the name of the team

Return Value

string

at line line 389
string getEscapedName()

Get the name of the team, safe for use in your HTML

Return Value

string The name of the team

at line line 402
int getNumMembers()

Get the number of members on the team

Return Value

int The number of members on the team

at line line 412
int getNumTotalMatches()

Get the total number of matches this team has played

Return Value

int The total number of matches this team has played

at line line 424
int getRankValue()

Get the rank category a team belongs too based on their ELO

This value is always a multiple of 100 and less than or equal to 2000

Return Value

int The rank category a team belongs to

at line line 434
string getRankImageLiteral()

Get the HTML for an image with the rank symbol

Return Value

string The HTML for a rank image

at line line 444
incrementMatchCount(string $type)

Increment the team's match count by one

Parameters

string $type The type of the match. Can be 'win', 'draw' or 'loss'

at line line 456
bool isMember(int $playerID)

Check if a player is part of this team

Parameters

int $playerID The player to check

Return Value

bool True if the player belongs to this team

at line line 469
void removeMember(int $id)

Removes a member from the team

Parameters

int $id The id of the player to remove

Return Value

void

at line line 487
void setDescription(string $description)

Update the description of the team

Parameters

string $description The description of the team written as markdown

Return Value

void

at line line 498
Team setStatus(string $newStatus)

Change the status of the team

Parameters

string $newStatus The new status of the team (open, closed, disabled or deleted)

Return Value

Team

at line line 509
Team setLeader(int $leader)

Change the leader of the team

Parameters

int $leader The ID of the new leader of the team

Return Value

Team

at line line 520
bool isLastMatch(int|Match $match)

Find if a specific match is the team's last one

Parameters

int|Match $match The match

Return Value

bool

at line line 533
void delete()

Delete the object

Please note that this does not delete the object entirely from the database, it only hides it from users. You should overload this function if your object does not have a 'status' column which can be set to 'deleted'.

Return Value

void

at line line 555
static Team createTeam(string $name, int $leader, string $avatar, string $description, string $status = 'closed', string|TimeDate $created = 'now')

Create a new team

Parameters

string $name The name of the team
int $leader The ID of the person creating the team, also the leader
string $avatar The URL to the team's avatar
string $description The team's description
string $status The team's status (open, closed, disabled or deleted)
string|TimeDate $created The date the team was created

Return Value

Team An object that represents the newly created team

at line line 586
static Team[] getTeams()

Get all the teams in the database that are not disabled or deleted

Return Value

Team[] An array of Team IDs

at line line 602
static Team getFromName(string $name)

Get a single team by its name

Parameters

string $name The team name to look for

Return Value

Team

at line line 613
static Closure getAlphabeticalSort()

Alphabetical order function for use in usort (case-insensitive)

Return Value

Closure The sort function

at line line 623
static string[] getActiveStatuses()

Get the possible statuses representing an active model (visible to everyone)

Return Value

string[]

at line line 632
static QueryBuilder getQueryBuilder()

Get a query builder for teams

Return Value

QueryBuilder