Merge branch 'task/absent-bye' into develop

This commit is contained in:
Jeroen De Meerleer 2019-05-13 20:03:25 +02:00
commit 2747bd0476
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -8,6 +8,7 @@
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Models\Round as RoundModel; use JeroenED\Libpairtwo\Models\Round as RoundModel;
use JeroenED\Libpairtwo\Game; use JeroenED\Libpairtwo\Game;
use JeroenED\Libpairtwo\Pairing; use JeroenED\Libpairtwo\Pairing;
@ -37,4 +38,40 @@ class Round extends RoundModel
$newarray[] = $pairing; $newarray[] = $pairing;
$this->setPairings($newarray); $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;
}
} }