From 6115d00821ec062c0571e79063271967eb060a6b Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 1 May 2019 19:20:50 +0200 Subject: [PATCH] Created Showing the pairings of a specific player (markdown) --- Showing-the-pairings-of-a-specific-player.md | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Showing-the-pairings-of-a-specific-player.md diff --git a/Showing-the-pairings-of-a-specific-player.md b/Showing-the-pairings-of-a-specific-player.md new file mode 100644 index 0000000..77ecba9 --- /dev/null +++ b/Showing-the-pairings-of-a-specific-player.md @@ -0,0 +1,31 @@ +You can show the pairings of a specific player by using the `Player::getPairings()` method. To get the specific player you can use the static function `Player::getPlayersByName()`. + +## Example + +```php +getTournament()); + +$magnus = $magnusses[0]; + +foreach ($magnus->getPairings() as $game) { + $player = $pairing->getPlayer()->getName(); + if (!is_null($pairing->getOpponent())) { + $opponent = $pairing->getOpponent()->getName(); + $color = $pairing->getColor()->getKey(); + echo $player . ' against ' . $opponent . ' using ' . $color . PHP_EOL; + } elseif ($pairing->getResult() == Result::bye ) { + echo $player . ' is bye' . PHP_EOL; + } elseif ($pairing->getResult() == Result::absent ) { + echo $player . ' is absent' . PHP_EOL; + } +} +``` \ No newline at end of file