Round
extends HierarchyBase
in package
implements
WithSkipSetters, WithTeams, WithGroups, WithGames
Uses
WithTeams, WithGroups, WithSkipSetters, WithGames
Tournament round
Round is a container for tournament groups. Groups in a round are played at the same time. This modifies the generation of games - generate all games for each group and play them in alternating order (game 1 from group 1, game 1 from group 2, game 2 from group 1, ...).
Tags
Interfaces, Classes and Traits
- WithSkipSetters
- Interface that allows for setting skipping of not-playable games
- WithTeams
- Functions for objects that contain teams
- WithGroups
- Interface for objects that contain groups
- WithGames
- Interface for objects that contain games
Table of Contents
- $container : HierarchyContainer
- $games : GameContainer
- $id : string|int
- $name : string
- $teams : TeamContainer
- $allowSkip : bool
- __construct() : mixed
- Round constructor.
- __toString() : string
- addGameContainer() : WithGames
- Add a child container for games
- addGroup() : $this
- Adds one or more group to round
- addTeam() : WithTeams
- Add one or more teams into the object.
- addTeamContainer() : WithTeams
- Add a child container for games
- allowSkip() : $this
- Allows round skipping
- disallowSkip() : $this
- Disallow round skipping
- export() : ExporterInterface
- Prepares a general hierarchy exporter for this hierarchy class
- filterTeams() : array<string|int, mixed>
- Filter teams using the specified filters
- genGames() : array<string|int, mixed>
- Generate all games
- getContainer() : HierarchyContainer
- Get the hierarchy container
- getGameContainer() : GameContainer
- Get the container for games
- getGames() : array<string|int, Game>
- Get all tournament games
- getGroups() : array<string|int, Group>
- Get all groups in this object
- getGroupsIds() : array<string|int, string>|array<string|int, int>
- Get all group ids
- getId() : string|int
- Gets the unique identifier of the object
- getName() : string
- Gets the name of the object
- getSkip() : bool
- Getter for round skipping
- getTeamContainer() : TeamContainer
- Get the container for games
- getTeams() : array<string|int, Team>
- Get all teams in the object
- group() : Group
- Creates a new group and adds it to round
- insertIntoContainer() : $this
- Insert into hierarchical container
- isPlayed() : bool
- Check if all games in this round has been played
- orderGroups() : array<string|int, Group>
- Sort groups by their order
- progress() : $this
- Progresses all teams from the round
- queryGroups() : ContainerQuery
- Get groups container query
- resetGames() : $this
- Reset all game results as if they were not played
- setGameAutoincrementId() : WithGames
- Sets a new autoincrement value (start) for the generated games
- setId() : self
- Sets the unique identifier of the object
- setName() : self
- Sets the name of the object
- setResults() : Game|null
- Set the game's results
- setSkip() : $this
- Set round skipping
- simulate() : $this
- Simulate all games in this round as they would be played for real
- sortTeams() : array<string|int, Team>
- Sort the teams by their score/points
- splitTeams() : $this
- Split teams into its Groups
- team() : Team
- Create a new team and add it into the object
Properties
$container
protected
HierarchyContainer
$container
$games
protected
GameContainer
$games
$id
protected
string|int
$id
$name
protected
string
$name
= ''
$teams
protected
TeamContainer
$teams
$allowSkip
private
bool
$allowSkip
= false
Methods
__construct()
Round constructor.
public
__construct([string $name = '' ][, string|int|null $id = null ]) : mixed
Parameters
- $name : string = ''
-
Round name
- $id : string|int|null = null
-
Round id - if omitted -> it is generated automatically as unique string
Return values
mixed —__toString()
public
__toString() : string
Return values
string —Name of the object
addGameContainer()
Add a child container for games
public
addGameContainer(GameContainer $container) : WithGames
Parameters
- $container : GameContainer
Tags
Return values
WithGames —addGroup()
Adds one or more group to round
public
addGroup(Group ...$groups) : $this
Parameters
- $groups : Group
Return values
$this —addTeam()
Add one or more teams into the object.
public
addTeam(Team ...$teams) : WithTeams
Parameters
- $teams : Team
-
Team objects
Return values
WithTeams —addTeamContainer()
Add a child container for games
public
addTeamContainer(TeamContainer $container) : WithTeams
Parameters
- $container : TeamContainer
Return values
WithTeams —allowSkip()
Allows round skipping
public
allowSkip() : $this
Return values
$this —disallowSkip()
Disallow round skipping
public
disallowSkip() : $this
Return values
$this —export()
Prepares a general hierarchy exporter for this hierarchy class
public
export() : ExporterInterface
Return values
ExporterInterface —filterTeams()
Filter teams using the specified filters
public
filterTeams(array<string|int, mixed> &$teams, array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>> $filters) : array<string|int, mixed>
Parameters
- $teams : array<string|int, mixed>
-
Teams to filter through
- $filters : array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>>
-
Filters to use
Tags
Return values
array<string|int, mixed> —genGames()
Generate all games
public
genGames() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getContainer()
Get the hierarchy container
public
getContainer() : HierarchyContainer
Return values
HierarchyContainer —getGameContainer()
Get the container for games
public
getGameContainer() : GameContainer
Return values
GameContainer —getGames()
Get all tournament games
public
getGames() : array<string|int, Game>
Return values
array<string|int, Game> —getGroups()
Get all groups in this object
public
getGroups() : array<string|int, Group>
Return values
array<string|int, Group> —getGroupsIds()
Get all group ids
public
getGroupsIds() : array<string|int, string>|array<string|int, int>
Return values
array<string|int, string>|array<string|int, int> —Array of ids
getId()
Gets the unique identifier of the object
public
getId() : string|int
Return values
string|int —Unique identifier of the object
getName()
Gets the name of the object
public
getName() : string
Return values
string —Name of the object
getSkip()
Getter for round skipping
public
getSkip() : bool
Return values
bool —getTeamContainer()
Get the container for games
public
getTeamContainer() : TeamContainer
Return values
TeamContainer —getTeams()
Get all teams in the object
public
getTeams([bool $ordered = false ][, string|null $ordering = Constants::POINTS ][, array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>> $filters = [] ]) : array<string|int, Team>
Parameters
- $ordered : bool = false
-
If true - order the teams by their score/points
- $ordering : string|null = Constants::POINTS
-
What to order the teams by - Constants::POINTS, Constants::SCORE
- $filters : array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>> = []
-
Filters to filter the returned teams (ex. if you only want to get the first 3 teams)
Tags
Return values
array<string|int, Team> —group()
Creates a new group and adds it to round
public
group(string $name[, string|int|null $id = null ]) : Group
Parameters
- $name : string
-
Group name
- $id : string|int|null = null
-
Group id - if omitted -> it is generated automatically as unique string
Return values
Group —New group
insertIntoContainer()
Insert into hierarchical container
public
insertIntoContainer(Base $object) : $this
Parameters
- $object : Base
Tags
Return values
$this —isPlayed()
Check if all games in this round has been played
public
isPlayed() : bool
Return values
bool —orderGroups()
Sort groups by their order
public
orderGroups() : array<string|int, Group>
Return values
array<string|int, Group> —Sorted groups
progress()
Progresses all teams from the round
public
progress([bool $blank = false ]) : $this
Parameters
- $blank : bool = false
-
If true -> creates dummy teams for (does not progress the real team objects) - used for simulation
Tags
Return values
$this —queryGroups()
Get groups container query
public
queryGroups() : ContainerQuery
Return values
ContainerQuery —resetGames()
Reset all game results as if they were not played
public
resetGames() : $this
Tags
Return values
$this —setGameAutoincrementId()
Sets a new autoincrement value (start) for the generated games
public
setGameAutoincrementId(int $id) : WithGames
Parameters
- $id : int
-
Id - probably from the database
Tags
Return values
WithGames —setId()
Sets the unique identifier of the object
public
setId(string|int $id) : self
Parameters
- $id : string|int
-
Unique identifier of the object
Tags
Return values
self —setName()
Sets the name of the object
public
setName(string $name) : self
Parameters
- $name : string
-
Name of the object
Return values
self —setResults()
Set the game's results
public
setResults(array<string|int, int> $results) : Game|null
Results is an array of [teamId => teamScore] key-value pairs. This method will look for a game with given teams and try to set the first not played.
Parameters
- $results : array<string|int, int>
-
array of [teamId => teamScore] key-value pairs
Tags
Return values
Game|null —setSkip()
Set round skipping
public
setSkip(bool $skip) : $this
Parameters
- $skip : bool
Return values
$this —simulate()
Simulate all games in this round as they would be played for real
public
simulate() : $this
Tags
Return values
$this —sortTeams()
Sort the teams by their score/points
public
sortTeams([string|null $ordering = Constants::POINTS ][, array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>> $filters = [] ]) : array<string|int, Team>
Parameters
- $ordering : string|null = Constants::POINTS
-
What to order the teams by - Constants::POINTS, Constants::SCORE
- $filters : array<string|int, TeamFilter>|array<string|int, array<string|int, TeamFilter>> = []
-
Filters to filter the returned teams (ex. if you only want to get the first 3 teams)
Tags
Return values
array<string|int, Team> —splitTeams()
Split teams into its Groups
public
splitTeams(array<string|int, Group> ...$groups) : $this
Parameters
- $groups : array<string|int, Group>
Tags
Return values
$this —team()
Create a new team and add it into the object
public
team([string $name = '' ][, string|int|null $id = null ]) : Team
Parameters
- $name : string = ''
-
Name of the new team
- $id : string|int|null = null
-
Id of the new team - if omitted -> it is generated automatically as unique string
Return values
Team —Newly created team