mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Removed fluent setters
This commit is contained in:
parent
07fdb769b2
commit
9e48bc1ff1
@ -32,5 +32,5 @@ interface ReaderInterface
|
|||||||
* @param $filename
|
* @param $filename
|
||||||
* @return ReaderInterface
|
* @return ReaderInterface
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): ReaderInterface;
|
public function read(string $filename): void;
|
||||||
}
|
}
|
||||||
|
@ -66,14 +66,12 @@ class Player
|
|||||||
* Adds a pairing to the tournament
|
* Adds a pairing to the tournament
|
||||||
*
|
*
|
||||||
* @param Pairing $pairing
|
* @param Pairing $pairing
|
||||||
* @return Player
|
|
||||||
*/
|
*/
|
||||||
public function addPairing(Pairing $pairing): Player
|
public function addPairing(Pairing $pairing): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Pairings;
|
$newArray = $this->Pairings;
|
||||||
$newArray[] = $pairing;
|
$newArray[] = $pairing;
|
||||||
$this->Pairings = $newArray;
|
$this->Pairings = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +113,6 @@ class Player
|
|||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param int $value
|
* @param int $value
|
||||||
* @return Player
|
|
||||||
*/
|
*/
|
||||||
public function setElo(string $type, int $value): void
|
public function setElo(string $type, int $value): void
|
||||||
{
|
{
|
||||||
@ -144,7 +141,6 @@ class Player
|
|||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return Player
|
|
||||||
*/
|
*/
|
||||||
public function setId(string $type, string $value): void
|
public function setId(string $type, string $value): void
|
||||||
{
|
{
|
||||||
@ -277,11 +273,9 @@ class Player
|
|||||||
*
|
*
|
||||||
* @param string $Key
|
* @param string $Key
|
||||||
* @param bool|int|DateTime|string $Value
|
* @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;
|
$this->BinaryData[$Key] = $Value;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,6 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
*
|
*
|
||||||
* @param string $Key
|
* @param string $Key
|
||||||
* @param bool|int|DateTime|string $Value
|
* @param bool|int|DateTime|string $Value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __set(string $Key, $Value): 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
|
* Reads out $swsfile and returns a Pairtwo6 class object
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return Pairtwo6
|
|
||||||
* @throws IncompatibleReaderException
|
* @throws IncompatibleReaderException
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): ReaderInterface
|
public function read(string $filename): void
|
||||||
{
|
{
|
||||||
$swshandle = fopen($filename, 'rb');
|
$swshandle = fopen($filename, 'rb');
|
||||||
$swscontents = fread($swshandle, filesize($filename));
|
$swscontents = fread($swshandle, filesize($filename));
|
||||||
@ -724,7 +722,6 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$this->addTiebreaks();
|
$this->addTiebreaks();
|
||||||
|
|
||||||
$this->Tournament->pairingsToRounds();
|
$this->Tournament->pairingsToRounds();
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -848,6 +845,5 @@ class Pairtwo6 implements ReaderInterface
|
|||||||
$tiebreaks = $this->Tournament->Tiebreaks;
|
$tiebreaks = $this->Tournament->Tiebreaks;
|
||||||
array_unshift($tiebreaks, $firstElement);
|
array_unshift($tiebreaks, $firstElement);
|
||||||
$this->Tournament->Tiebreaks = $tiebreaks;
|
$this->Tournament->Tiebreaks = $tiebreaks;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,9 @@ class Swar4 implements ReaderInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return ReaderInterface
|
|
||||||
* @throws IncompatibleReaderException
|
* @throws IncompatibleReaderException
|
||||||
*/
|
*/
|
||||||
public function read(string $filename): ReaderInterface
|
public function read(string $filename): void
|
||||||
{
|
{
|
||||||
$swshandle = fopen($filename, 'rb');
|
$swshandle = fopen($filename, 'rb');
|
||||||
|
|
||||||
@ -491,7 +490,6 @@ class Swar4 implements ReaderInterface
|
|||||||
fclose($swshandle);
|
fclose($swshandle);
|
||||||
$this->Tournament->pairingsToRounds();
|
$this->Tournament->pairingsToRounds();
|
||||||
$this->addTiebreaks();
|
$this->addTiebreaks();
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -580,7 +578,6 @@ class Swar4 implements ReaderInterface
|
|||||||
*
|
*
|
||||||
* @param string $Key
|
* @param string $Key
|
||||||
* @param bool|int|DateTime|string $Value
|
* @param bool|int|DateTime|string $Value
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __set(string $Key, $Value): void
|
public function __set(string $Key, $Value): void
|
||||||
{
|
{
|
||||||
@ -600,10 +597,7 @@ class Swar4 implements ReaderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function addTiebreaks(): void
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
private function addTiebreaks(): Swar4
|
|
||||||
{
|
{
|
||||||
switch ($this->Tournament->System) {
|
switch ($this->Tournament->System) {
|
||||||
case TournamentSystem::American:
|
case TournamentSystem::American:
|
||||||
@ -615,6 +609,5 @@ class Swar4 implements ReaderInterface
|
|||||||
$tiebreaks = $this->Tournament->Tiebreaks;
|
$tiebreaks = $this->Tournament->Tiebreaks;
|
||||||
array_unshift($tiebreaks, $firstElement);
|
array_unshift($tiebreaks, $firstElement);
|
||||||
$this->Tournament->Tiebreaks = $tiebreaks;
|
$this->Tournament->Tiebreaks = $tiebreaks;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,32 +55,28 @@ class Round
|
|||||||
*/
|
*/
|
||||||
public $Pairings = [];
|
public $Pairings = [];
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Adds a game to the round
|
* Adds a game to the round
|
||||||
*
|
*
|
||||||
* @param Game $game
|
* @param Game $game
|
||||||
* @return Round
|
|
||||||
*/
|
*/
|
||||||
public function addGame(Game $game): Round
|
public function addGame(Game $game): void
|
||||||
{
|
{
|
||||||
$newarray = $this->Games;
|
$newarray = $this->Games;
|
||||||
$newarray[] = $game;
|
$newarray[] = $game;
|
||||||
$this->Games = $newarray;
|
$this->Games = $newarray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a pairing to the round
|
* Adds a pairing to the round
|
||||||
*
|
*
|
||||||
* @param Pairing $pairing
|
* @param Pairing $pairing
|
||||||
* @return Round
|
|
||||||
*/
|
*/
|
||||||
public function addPairing(Pairing $pairing): Round
|
public function addPairing(Pairing $pairing): void
|
||||||
{
|
{
|
||||||
$newarray = $this->Pairings;
|
$newarray = $this->Pairings;
|
||||||
$newarray[] = $pairing;
|
$newarray[] = $pairing;
|
||||||
$this->Pairings = $newarray;
|
$this->Pairings = $newarray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,14 +120,13 @@ class Tournament
|
|||||||
* Adds a player
|
* Adds a player
|
||||||
*
|
*
|
||||||
* @param Player $Player
|
* @param Player $Player
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function addPlayer(Player $Player): Tournament
|
public function addPlayer(Player $Player): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Players;
|
$newArray = $this->Players;
|
||||||
$newArray[] = $Player;
|
$newArray[] = $Player;
|
||||||
$this->Players = $newArray;
|
$this->Players = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,42 +134,39 @@ class Tournament
|
|||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param Player $player
|
* @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 = $this->Players;
|
||||||
$newArray[$id] = $player;
|
$newArray[$id] = $player;
|
||||||
$this->Players = $newArray;
|
$this->Players = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a Tiebreak
|
* Adds a Tiebreak
|
||||||
*
|
*
|
||||||
* @param Tiebreak $tiebreak
|
* @param Tiebreak $tiebreak
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function addTiebreak(Tiebreak $tiebreak): Tournament
|
public function addTiebreak(Tiebreak $tiebreak): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Tiebreaks;
|
$newArray = $this->Tiebreaks;
|
||||||
$newArray[] = $tiebreak;
|
$newArray[] = $tiebreak;
|
||||||
$this->Tiebreaks = $newArray;
|
$this->Tiebreaks = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a round with given Round object
|
* Adds a round with given Round object
|
||||||
*
|
*
|
||||||
* @param Round $round
|
* @param Round $round
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function addRound(Round $round): Tournament
|
public function addRound(Round $round): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Rounds;
|
$newArray = $this->Rounds;
|
||||||
$newArray[$round->RoundNo] = $round;
|
$newArray[$round->RoundNo] = $round;
|
||||||
$this->Rounds = $newArray;
|
$this->Rounds = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,14 +184,13 @@ class Tournament
|
|||||||
* Adds a pairing to the tournament
|
* Adds a pairing to the tournament
|
||||||
*
|
*
|
||||||
* @param Pairing $pairing
|
* @param Pairing $pairing
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function addPairing(Pairing $pairing): Tournament
|
public function addPairing(Pairing $pairing): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Pairings;
|
$newArray = $this->Pairings;
|
||||||
$newArray[] = $pairing;
|
$newArray[] = $pairing;
|
||||||
$this->Pairings = $newArray;
|
$this->Pairings = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,22 +198,21 @@ class Tournament
|
|||||||
* Adds an arbiter to the tournament
|
* Adds an arbiter to the tournament
|
||||||
*
|
*
|
||||||
* @param string $Arbiter
|
* @param string $Arbiter
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function addArbiter(string $Arbiter): Tournament
|
public function addArbiter(string $Arbiter): void
|
||||||
{
|
{
|
||||||
$newArray = $this->Arbiters;
|
$newArray = $this->Arbiters;
|
||||||
$newArray[] = $Arbiter;
|
$newArray[] = $Arbiter;
|
||||||
$this->Arbiters = $newArray;
|
$this->Arbiters = $newArray;
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts pairings into games with a black and white player
|
* Converts pairings into games with a black and white player
|
||||||
*
|
*
|
||||||
* @return Tournament
|
*
|
||||||
*/
|
*/
|
||||||
public function pairingsToRounds(): Tournament
|
public function pairingsToRounds(): void
|
||||||
{
|
{
|
||||||
/** @var Pairing[] $pairings */
|
/** @var Pairing[] $pairings */
|
||||||
$pairings = $this->Pairings;
|
$pairings = $this->Pairings;
|
||||||
@ -282,7 +276,6 @@ class Tournament
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,9 +318,9 @@ class Tournament
|
|||||||
*
|
*
|
||||||
* @param Game $game
|
* @param Game $game
|
||||||
* @param int $round
|
* @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])) {
|
if (!isset($this->Rounds[$round])) {
|
||||||
$roundObj = new Round();
|
$roundObj = new Round();
|
||||||
@ -336,7 +329,6 @@ class Tournament
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->getRoundByNo($round)->addGame($game);
|
$this->getRoundByNo($round)->addGame($game);
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user