Tournament Generator

Category extends HierarchyBase
in package
implements WithSkipSetters, WithRounds, WithTeams, WithGroups, WithGames Uses WithTeams, WithRounds, WithGroups, WithSkipSetters, WithGames

Tournament category

Category is an optional container for rounds in a tournament. It separates a tournament into bigger chunks that are played separately one after another. This allows "sub-tournaments" in one tournament with the possibility to progress teams from one category to the next one.

Tags
author

Tomá? Vojík vojik@wboy.cz

since
0.1

Interfaces, Classes and Traits

WithSkipSetters
Interface that allows for setting skipping of not-playable games
WithRounds
Interface for objects that contain rounds
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
Category constructor.
__toString()  : string
addGameContainer()  : WithGames
Add a child container for games
addRound()  : $this
Adds round to the category
addTeam()  : WithTeams
Add one or more teams into the object.
addTeamContainer()  : WithTeams
Add a child container for games
allowSkip()  : $this
Allows skipping of games with less than the minimum amounts of games
disallowSkip()  : $this
Disallow round skipping
filterTeams()  : array<string|int, mixed>
Filter teams using the specified filters
genGamesSimulate()  : array<string|int, Game>
Simulate all games as they would be played in reality - with dummy teams
genGamesSimulateReal()  : array<string|int, Game>
Simulate all games as they would be played in reality - with real teams
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
getId()  : string|int
Gets the unique identifier of the object
getName()  : string
Gets the name of the object
getRounds()  : array<string|int, Round>
Get all rounds in this category
getSkip()  : bool
Getter for round skipping
getTeamContainer()  : TeamContainer
Get the container for games
getTeams()  : array<string|int, Team>
Get all teams in the object
insertIntoContainer()  : $this
Insert into hierarchical container
round()  : Round
Creates a new round and adds it to the category
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
setSkip()  : $this
Set round skipping
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

$id

protected string|int $id

$name

protected string $name = ''

Methods

__construct()

Category constructor.

public __construct([string $name = '' ][, string|int|null $id = null ]) : mixed
Parameters
$name : string = ''

Category name

$id : string|int|null = null

Category id - if omitted -> it is generated automatically as unique string

Return values
mixed

__toString()

public __toString() : string
Return values
string

Name of the object

addRound()

Adds round to the category

public addRound(Round ...$rounds) : $this
Parameters
$rounds : Round

One or more round objects

Return values
$this

allowSkip()

Allows skipping of games with less than the minimum amounts of games

public allowSkip() : $this
Return values
$this

disallowSkip()

Disallow round skipping

public disallowSkip() : $this
Return values
$this

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
throws
Exception
Return values
array<string|int, mixed>

genGamesSimulate()

Simulate all games as they would be played in reality - with dummy teams

public genGamesSimulate() : array<string|int, Game>
Tags
throws
Exception
Return values
array<string|int, Game>

Generated games, or expected play time

genGamesSimulateReal()

Simulate all games as they would be played in reality - with real teams

public genGamesSimulateReal() : array<string|int, Game>
Tags
throws
Exception
Return values
array<string|int, Game>

Generated games, or expected play time

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>

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

getRounds()

Get all rounds in this category

public getRounds() : array<string|int, Round>
Return values
array<string|int, Round>

getSkip()

Getter for round skipping

public getSkip() : bool
Return values
bool

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
throws
Exception
Return values
array<string|int, Team>

insertIntoContainer()

Insert into hierarchical container

public insertIntoContainer(Base $object) : $this
Parameters
$object : Base
Tags
post

Object is added to hierarchy

post

If the object has teams -> add other team container to hierarchy

post

If the object has games -> add other game container to hierarchy

Return values
$this

round()

Creates a new round and adds it to the category

public round([string $name = '' ][, string|int|null $id = null ]) : Round
Parameters
$name : string = ''

Round name

$id : string|int|null = null

Round id - if omitted -> it is generated automatically as unique string

Return values
Round

The newly created round

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
warning

Do this on the top-level hierarchy element (Tournament class) or else, it might be reset later

post

Propagates the value to all child hierarchy objects

see
GameContainer::setAutoIncrement()
since
0.5
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
throws
InvalidArgumentException

if the provided argument is not of type 'string' or 'int'

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

setSkip()

Set round skipping

public setSkip(bool $skip) : $this
Parameters
$skip : bool
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
throws
Exception
Return values
array<string|int, Team>

splitTeams()

Split teams into its Groups

public splitTeams(Round ...$wheres) : $this
Parameters
$wheres : Round
Tags
throws
Exception
noinspection

CallableParameterUseCaseInTypeContextInspection

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

Search results