diff --git a/src/Player.php b/src/Player.php index 027f946..50d4478 100644 --- a/src/Player.php +++ b/src/Player.php @@ -66,12 +66,14 @@ class Player * Adds a pairing to the tournament * * @param Pairing $pairing + * @return Player */ - public function addPairing(Pairing $pairing) + public function addPairing(Pairing $pairing): Player { $newArray = $this->GetPairings(); $newArray[] = $pairing; $this->setPairings($newArray); + return $this; } /** @@ -145,7 +147,7 @@ class Player /** * @return int */ - public function getNoOfWins() + public function getNoOfWins(): int { $wins = 0; foreach ($this->getPairings() as $pairing) { @@ -176,7 +178,7 @@ class Player /** * @return int */ - public function getPerformance(string $type, int $unratedElo) : float + public function getPerformance(string $type, int $unratedElo): float { $total = 0; $opponents = 0; diff --git a/src/Tournament.php b/src/Tournament.php index e7322fe..7a69274 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -107,7 +107,7 @@ class Tournament * @param integer $id * @return Player */ - public function getPlayerById(int $id) + public function getPlayerById(int $id): Player { return $this->GetPlayers()[$id]; } @@ -116,12 +116,14 @@ class Tournament * Adds a player * * @param Player $Player + * @return Tournament */ - public function addPlayer(Player $Player) + public function addPlayer(Player $Player): Tournament { $newArray = $this->GetPlayers(); $newArray[] = $Player; $this->setPlayers($newArray); + return $this; } /** @@ -129,36 +131,42 @@ class Tournament * * @param int $id * @param Player $player + * @return Tournament */ - public function updatePlayer(int $id, Player $player) + public function updatePlayer(int $id, Player $player): Tournament { $newArray = $this->GetPlayers(); $newArray[$id] = $player; $this->setPlayers($newArray); + return $this; } /** * Adds a Tiebreak * * @param Tiebreak $tiebreak + * @return Tournament */ - public function addTiebreak(Tiebreak $tiebreak) + public function addTiebreak(Tiebreak $tiebreak): Tournament { $newArray = $this->getTiebreaks(); $newArray[] = $tiebreak; $this->setTiebreaks($newArray); + return $this; } /** * Adds a round with given Round object * * @param Round $round + * @return Tournament */ - public function addRound(Round $round) + public function addRound(Round $round): Tournament { $newArray = $this->getRounds(); $newArray[$round->getRoundNo()] = $round; $this->setRounds($newArray); + return $this; } /** @@ -176,18 +184,22 @@ class Tournament * Adds a pairing to the tournament * * @param Pairing $pairing + * @return Tournament */ - public function addPairing(Pairing $pairing) + public function addPairing(Pairing $pairing): Tournament { $newArray = $this->GetPairings(); $newArray[] = $pairing; $this->setPairings($newArray); + return $this; } /** * Converts pairings into games with a black and white player + * + * @return Tournament */ - public function pairingsToRounds(): void + public function pairingsToRounds(): Tournament { /** @var Pairing[] $pairings */ $pairings = $this->getPairings(); @@ -230,6 +242,7 @@ class Tournament } } } + return $this; } /**