Tournament Generator

HierarchyContainer extends BaseContainer

Class HierarchyContainer

HierarchyContainer is a special type of container specifically for creating hierarchies on Tournament->Category->Round->Group.

Tags
author

Tomáš Vojík vojik@wboy.cz

since
0.4

Table of Contents

$id  : string|int
$children  : array<string|int, mixed>
$currentIndex  : int
$parent  : BaseContainer|null
$type  : string|null
$values  : array<string|int, mixed>
__construct()  : mixed
BaseContainer constructor.
addChild()  : $this
Adds a child container
addSorter()  : ContainerQuery
count()  : int
Returns the value count
current()  : mixed
Get the current value
filter()  : ContainerQuery
Add a filter callback
fromArray()  : BaseContainer
Create a new container from array
get()  : array<string|int, mixed>
Get all values from the container - including child nodes
getHierarchyLevel()  : array<string|int, Base>
Returns a hierarchy level of objects that contains the given classes
getHierarchyLevelQuery()  : ContainerQuery
Returns a container query for a set hierarchy level
getLeafIds()  : array<string|int, string>|array<string|int, int>
Gets all ids of the leaf containers
getLevelType()  : string|null
Get current level's type
getParent()  : BaseContainer|null
Get a parent container
getQuery()  : ContainerQuery
getTopLevel()  : array<string|int, mixed>
Get all top-level values from the container
getTopLevelQuery()  : ContainerQuery
ids()  : ContainerQuery
Get only the object's ids
insert()  : $this
Insert a value into container
insertFlat()  : $this
Insert a value into container
key()  : int
Return the current key
next()  : void
Move pointer to next
only()  : ContainerQuery
Pluck a specific key from all values
rewind()  : void
Rewind the iterator
setParent()  : BaseContainer
Set a container's parent
sort()  : ContainerQuery
Sort a result using a callback - maintaining the index association
sortBy()  : ContainerQuery
Sort a result set by a given property
unique()  : ContainerQuery
Get only unique values
valid()  : bool
Check if the current value exists
whereId()  : ContainerQuery
Filter results to only contain those with a specific ID

Properties

Methods

__construct()

BaseContainer constructor.

public __construct(string|int $id[, BaseContainer $parent = null ]) : mixed
Parameters
$id : string|int
$parent : BaseContainer = null
Return values
mixed

addChild()

Adds a child container

public addChild(array<string|int, BaseContainer...$containers) : $this
Parameters
$containers : array<string|int, BaseContainer>
Tags
post

Parent container is set for the added children

throws
Exception
Return values
$this

count()

Returns the value count

public count() : int
Return values
int

current()

Get the current value

public current() : mixed
Return values
mixed

fromArray()

Create a new container from array

public static fromArray(array<string|int, mixed> $data) : BaseContainer
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception
Return values
BaseContainer

get()

Get all values from the container - including child nodes

public get() : array<string|int, mixed>
Return values
array<string|int, mixed>

All values

getHierarchyLevel()

Returns a hierarchy level of objects that contains the given classes

public getHierarchyLevel( $class) : array<string|int, Base>
Parameters
$class :
Return values
array<string|int, Base>

getLeafIds()

Gets all ids of the leaf containers

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

getLevelType()

Get current level's type

public getLevelType() : string|null
Return values
string|null

getTopLevel()

Get all top-level values from the container

public getTopLevel() : array<string|int, mixed>
Return values
array<string|int, mixed>

All values

insert()

Insert a value into container

public insert(mixed ...$values) : $this
Parameters
$values : mixed

Any value to insert into container

Return values
$this

insertFlat()

Insert a value into container

public insertFlat(array<string|int, mixed> ...$values) : $this
Parameters
$values : array<string|int, mixed>

Any value to insert into container

Tags
throws
Exception
Return values
$this

key()

Return the current key

public key() : int
Return values
int

next()

Move pointer to next

public next() : void
Return values
void

only()

Pluck a specific key from all values

public only(string $property) : ContainerQuery
Parameters
$property : string

Property, array key or method to extract from values

Tags
throws
Exception
Return values
ContainerQuery

rewind()

Rewind the iterator

public rewind() : void
Return values
void

sortBy()

Sort a result set by a given property

public sortBy(string $property) : ContainerQuery
Parameters
$property : string
Tags
warning

Sort callback has a priority.

Return values
ContainerQuery

valid()

Check if the current value exists

public valid() : bool
Return values
bool

Search results