Game
in package
implements
WithId, Exportable
Class Game
Tags
Interfaces, Classes and Traits
- WithId
- Identifies an object with an ID
- Exportable
- Interface Exportable
Table of Contents
- $group : Group
- $id : int
- $lossId : int|string
- $results : array<string|int, mixed>
- $teams : array<string|int, mixed>
- $winId : int|string
- $drawIds : array<string|int, mixed>
- $secondId : int|string
- $thirdId : int|string
- __construct() : mixed
- Game constructor.
- addTeam() : $this
- Add teams to this game
- export() : ExporterInterface
- Prepares an export query for the object
- getDraw() : array<string|int, int>|array<string|int, string>
- Get the draws teams' id
- getGroup() : Group
- Get the parent group object
- getId() : int
- Gets the unique identifier of the object
- getLoss() : int|string
- Get the losing team's id
- getResults() : array<string|int, array<string|int, mixed>>
- Get results
- getSecond() : int|string
- Get the second team's id
- getTeam() : Team|null
- Get team by ID
- getTeams() : array<string|int, Team>
- Get all teams from the game
- getTeamsIds() : array<string|int, string>|array<string|int, int>
- Get all team ids from this game
- getThird() : int|string
- Get the third team's id
- getWin() : int|string
- Get the winning team's id
- isPlayed() : bool
- Check if the game has been played
- resetResults() : $this
- Reset the game's results
- setId() : Game
- Sets the unique identifier of the object
- setResults() : $this
- Set the game's results
- resetTeamScore() : void
- Resets a score for a team
- setResults2() : $this
- Set results for 2 team game
- setResults3() : $this
- Set results for 3 team game
- setResults4() : Game
- Set results for 4 team game
- setTeamScore() : void
- Set a score for a team
Properties
$group
protected
Group
$group
$id
protected
int
$id
$lossId
protected
int|string
$lossId
$results
protected
array<string|int, mixed>
$results
= []
$teams
protected
array<string|int, mixed>
$teams
$winId
protected
int|string
$winId
$drawIds
private
array<string|int, mixed>
$drawIds
= []
$secondId
private
int|string
$secondId
$thirdId
private
int|string
$thirdId
Methods
__construct()
Game constructor.
public
__construct(array<string|int, Team> $teams, Group $group) : mixed
Parameters
- $teams : array<string|int, Team>
-
Teams that play in this game
- $group : Group
-
Group that this game belongs to
Return values
mixed —addTeam()
Add teams to this game
public
addTeam(array<string|int, Team> ...$teams) : $this
Parameters
- $teams : array<string|int, Team>
Return values
$this —export()
Prepares an export query for the object
public
export() : ExporterInterface
Return values
ExporterInterface —Exporter for this class
getDraw()
Get the draws teams' id
public
getDraw() : array<string|int, int>|array<string|int, string>
Return values
array<string|int, int>|array<string|int, string> —getGroup()
Get the parent group object
public
getGroup() : Group
Return values
Group —getId()
Gets the unique identifier of the object
public
getId() : int
Tags
Return values
int —getLoss()
Get the losing team's id
public
getLoss() : int|string
Return values
int|string —getResults()
Get results
public
getResults() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>> —getSecond()
Get the second team's id
public
getSecond() : int|string
Return values
int|string —getTeam()
Get team by ID
public
getTeam(string|int $id) : Team|null
Parameters
- $id : string|int
-
Team ID
Return values
Team|null —getTeams()
Get all teams from the game
public
getTeams() : array<string|int, Team>
Return values
array<string|int, Team> —getTeamsIds()
Get all team ids from this game
public
getTeamsIds() : array<string|int, string>|array<string|int, int>
Return values
array<string|int, string>|array<string|int, int> —getThird()
Get the third team's id
public
getThird() : int|string
Return values
int|string —getWin()
Get the winning team's id
public
getWin() : int|string
Return values
int|string —isPlayed()
Check if the game has been played
public
isPlayed() : bool
Return values
bool —resetResults()
Reset the game's results
public
resetResults() : $this
Tags
Return values
$this —setId()
Sets the unique identifier of the object
public
setId(int $id) : Game
Parameters
- $id : int
Tags
Return values
Game —setResults()
Set the game's results
public
setResults([array<string|int, int> $results = [] ]) : $this
Results is an array of [teamId => teamScore] key-value pairs.
Parameters
- $results : array<string|int, int> = []
-
array of [teamId => teamScore] key-value pairs
Tags
Return values
$this —resetTeamScore()
Resets a score for a team
protected
resetTeamScore(string|int $teamId, array<string|int, mixed> $score) : void
Parameters
- $teamId : string|int
- $score : array<string|int, mixed>
Tags
Return values
void —setResults2()
Set results for 2 team game
protected
setResults2(int $teamPosition, int $score, array<string|int, int> $results, Team $team) : $this
Parameters
- $teamPosition : int
-
Team's position (first = 1, second = 2)
- $score : int
-
Team's score
- $results : array<string|int, int>
-
Results array (for draw checking)
- $team : Team
-
Team object
Tags
Return values
$this —setResults3()
Set results for 3 team game
protected
setResults3(int $teamPosition, Team $team) : $this
Parameters
- $teamPosition : int
-
Team's position (first = 1, second = 2, third = 3)
- $team : Team
-
Team object
Tags
Return values
$this —setResults4()
Set results for 4 team game
protected
setResults4(int $teamPosition, Team $team) : Game
Parameters
- $teamPosition : int
-
Team's position (first = 1, second = 2, third = 3, fourth = 4)
- $team : Team
-
Team object
Tags
Return values
Game —setTeamScore()
Set a score for a team
protected
setTeamScore(int $position, Team $team, array<string|int, int> $results, int $score) : void
Parameters
- $position : int
-
Team's position
- $team : Team
- $results : array<string|int, int>
-
The whole results set
- $score : int
-
Team's score