mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-29 09:46:42 +01:00
NEW FEATURE: Absent and Bye players
2 new functions added: Round::GetBye(): array and Round::GetAbsent():array Both returns an array of Pairing objects with Bye or Absent pairings
This commit is contained in:
parent
784e54b55b
commit
d593b654b4
@ -8,6 +8,7 @@
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
||||
use JeroenED\Libpairtwo\Game;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
@ -37,4 +38,40 @@ class Round extends RoundModel
|
||||
$newarray[] = $pairing;
|
||||
$this->setPairings($newarray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of pairings where the player is bye
|
||||
*
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getBye(): array
|
||||
{
|
||||
$allPairings = $this->getPairings();
|
||||
$byePairings = [];
|
||||
foreach ($allPairings as $pairing) {
|
||||
if ($pairing->getResult() == Result::bye) {
|
||||
$byePairings[] = $pairing;
|
||||
}
|
||||
}
|
||||
return $byePairings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of pairings where the player is absent
|
||||
*
|
||||
* @return Pairing[]
|
||||
*/
|
||||
public function getAbsent(): array
|
||||
{
|
||||
$allPairings = $this->getPairings();
|
||||
$absentPairings = [];
|
||||
foreach ($allPairings as $pairing) {
|
||||
if ($pairing->getResult() == Result::absent) {
|
||||
$absentPairings[] = $pairing;
|
||||
}
|
||||
}
|
||||
return $absentPairings;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user