Removed fluent setters

This commit is contained in:
Jeroen De Meerleer 2019-11-16 14:24:07 +01:00
parent 07fdb769b2
commit 9e48bc1ff1
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
6 changed files with 25 additions and 54 deletions

View File

@ -32,5 +32,5 @@ interface ReaderInterface
* @param $filename
* @return ReaderInterface
*/
public function read(string $filename): ReaderInterface;
public function read(string $filename): void;
}

View File

@ -66,14 +66,12 @@ class Player
* Adds a pairing to the tournament
*
* @param Pairing $pairing
* @return Player
*/
public function addPairing(Pairing $pairing): Player
public function addPairing(Pairing $pairing): void
{
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->Pairings = $newArray;
return $this;
}
/**
@ -115,7 +113,6 @@ class Player
*
* @param string $type
* @param int $value
* @return Player
*/
public function setElo(string $type, int $value): void
{
@ -144,7 +141,6 @@ class Player
*
* @param string $type
* @param string $value
* @return Player
*/
public function setId(string $type, string $value): void
{
@ -277,11 +273,9 @@ class Player
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return Player
*/
public function __set(string $Key, $Value): Player
public function __set(string $Key, $Value): void
{
$this->BinaryData[$Key] = $Value;
return $this;
}
}

View File

@ -73,7 +73,6 @@ class Pairtwo6 implements ReaderInterface
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return void
*/
public function __set(string $Key, $Value): void
{
@ -84,10 +83,9 @@ class Pairtwo6 implements ReaderInterface
* Reads out $swsfile and returns a Pairtwo6 class object
*
* @param string $filename
* @return Pairtwo6
* @throws IncompatibleReaderException
*/
public function read(string $filename): ReaderInterface
public function read(string $filename): void
{
$swshandle = fopen($filename, 'rb');
$swscontents = fread($swshandle, filesize($filename));
@ -724,7 +722,6 @@ class Pairtwo6 implements ReaderInterface
$this->addTiebreaks();
$this->Tournament->pairingsToRounds();
return $this;
}
/**
@ -848,6 +845,5 @@ class Pairtwo6 implements ReaderInterface
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
return $this;
}
}

View File

@ -106,10 +106,9 @@ class Swar4 implements ReaderInterface
/**
* @param string $filename
* @return ReaderInterface
* @throws IncompatibleReaderException
*/
public function read(string $filename): ReaderInterface
public function read(string $filename): void
{
$swshandle = fopen($filename, 'rb');
@ -491,7 +490,6 @@ class Swar4 implements ReaderInterface
fclose($swshandle);
$this->Tournament->pairingsToRounds();
$this->addTiebreaks();
return $this;
}
/**
@ -580,7 +578,6 @@ class Swar4 implements ReaderInterface
*
* @param string $Key
* @param bool|int|DateTime|string $Value
* @return void
*/
public function __set(string $Key, $Value): void
{
@ -600,10 +597,7 @@ class Swar4 implements ReaderInterface
}
}
/**
* @return $this
*/
private function addTiebreaks(): Swar4
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::American:
@ -615,6 +609,5 @@ class Swar4 implements ReaderInterface
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
return $this;
}
}

View File

@ -55,32 +55,28 @@ class Round
*/
public $Pairings = [];
/**
/*
* Adds a game to the round
*
* @param Game $game
* @return Round
*/
public function addGame(Game $game): Round
public function addGame(Game $game): void
{
$newarray = $this->Games;
$newarray[] = $game;
$this->Games = $newarray;
return $this;
}
/**
* Adds a pairing to the round
*
* @param Pairing $pairing
* @return Round
*/
public function addPairing(Pairing $pairing): Round
public function addPairing(Pairing $pairing): void
{
$newarray = $this->Pairings;
$newarray[] = $pairing;
$this->Pairings = $newarray;
return $this;
}
/**

View File

@ -120,14 +120,13 @@ class Tournament
* Adds a player
*
* @param Player $Player
* @return Tournament
*
*/
public function addPlayer(Player $Player): Tournament
public function addPlayer(Player $Player): void
{
$newArray = $this->Players;
$newArray[] = $Player;
$this->Players = $newArray;
return $this;
}
/**
@ -135,42 +134,39 @@ class Tournament
*
* @param int $id
* @param Player $player
* @return Tournament
*
*/
public function updatePlayer(int $id, Player $player): Tournament
public function updatePlayer(int $id, Player $player): void
{
$newArray = $this->Players;
$newArray[$id] = $player;
$this->Players = $newArray;
return $this;
}
/**
* Adds a Tiebreak
*
* @param Tiebreak $tiebreak
* @return Tournament
*
*/
public function addTiebreak(Tiebreak $tiebreak): Tournament
public function addTiebreak(Tiebreak $tiebreak): void
{
$newArray = $this->Tiebreaks;
$newArray[] = $tiebreak;
$this->Tiebreaks = $newArray;
return $this;
}
/**
* Adds a round with given Round object
*
* @param Round $round
* @return Tournament
*
*/
public function addRound(Round $round): Tournament
public function addRound(Round $round): void
{
$newArray = $this->Rounds;
$newArray[$round->RoundNo] = $round;
$this->Rounds = $newArray;
return $this;
}
/**
@ -188,14 +184,13 @@ class Tournament
* Adds a pairing to the tournament
*
* @param Pairing $pairing
* @return Tournament
*
*/
public function addPairing(Pairing $pairing): Tournament
public function addPairing(Pairing $pairing): void
{
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->Pairings = $newArray;
return $this;
}
@ -203,22 +198,21 @@ class Tournament
* Adds an arbiter to the tournament
*
* @param string $Arbiter
* @return Tournament
*
*/
public function addArbiter(string $Arbiter): Tournament
public function addArbiter(string $Arbiter): void
{
$newArray = $this->Arbiters;
$newArray[] = $Arbiter;
$this->Arbiters = $newArray;
return $this;
}
/**
* Converts pairings into games with a black and white player
*
* @return Tournament
*
*/
public function pairingsToRounds(): Tournament
public function pairingsToRounds(): void
{
/** @var Pairing[] $pairings */
$pairings = $this->Pairings;
@ -282,7 +276,6 @@ class Tournament
}
}
}
return $this;
}
/**
@ -325,9 +318,9 @@ class Tournament
*
* @param Game $game
* @param int $round
* @return Tournament
*
*/
public function addGame(Game $game, int $round): Tournament
public function addGame(Game $game, int $round): void
{
if (!isset($this->Rounds[$round])) {
$roundObj = new Round();
@ -336,7 +329,6 @@ class Tournament
}
$this->getRoundByNo($round)->addGame($game);
return $this;
}
/**