mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Created function Round::getGamesbyBoard
This commit is contained in:
parent
5314bc47f2
commit
575b786079
@ -117,6 +117,33 @@ class Round
|
||||
return $absentPairings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns an array with the games of this round sorted by board
|
||||
*
|
||||
* @return Game[]
|
||||
*/
|
||||
public function getGamesByBoard(): array
|
||||
{
|
||||
$allGames = $this->getGames();
|
||||
usort($allGames, array($this, 'sortByBoard'));
|
||||
return $allGames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort by board
|
||||
*
|
||||
* @param Game $a
|
||||
* @param Game $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortByBoard(Game $a, Game $b): int
|
||||
{
|
||||
if (($a->getBoard() == $b->getBoard()) || ($a->getBoard() === false) || ($b->getBoard() === false)) {
|
||||
return 0;
|
||||
}
|
||||
return ($a->getBoard() > $b->getBoard()) ? +1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date of the round
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user