diff --git a/src/Constants.php b/src/Constants.php index 8950dd2..68ec994 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -27,11 +27,11 @@ use JeroenED\Libpairtwo\Enums\Result; */ class Constants { - const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ]; - const Draw = [ Result::draw, Result::drawadjourned ]; - const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ]; - const NotPlayed = [ Result::bye, Result::wonbye, Result::absent ]; - const Played = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned, Result::draw, Result::drawadjourned, Result::absent, Result::bye, Result::lost, Result::adjourned ]; - const Black = [ Color::black ]; - const White = [ Color::white ]; + const Won = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned ]; + const Draw = [ Result::Draw, Result::DrawAdjourned ]; + const Lost = [ Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ]; + const NotPlayed = [ Result::Bye, Result::WonBye, Result::Absent ]; + const Played = [ Result::Won, Result::WonForfait, Result::WonBye, Result::WonAdjourned, Result::Draw, Result::DrawAdjourned, Result::Absent, Result::Bye, Result::Lost, Result::Adjourned ]; + const Black = [ Color::Black ]; + const White = [ Color::White ]; } diff --git a/src/Enums/Color.php b/src/Enums/Color.php index 9f35580..32d4827 100644 --- a/src/Enums/Color.php +++ b/src/Enums/Color.php @@ -26,7 +26,7 @@ use MyCLabs\Enum\Enum; */ class Color extends Enum { - const black = 'B'; - const white = 'W'; - const none = '*'; + const Black = 'B'; + const White = 'W'; + const None = '*'; } diff --git a/src/Enums/Result.php b/src/Enums/Result.php index a064612..15922a2 100644 --- a/src/Enums/Result.php +++ b/src/Enums/Result.php @@ -26,15 +26,15 @@ use MyCLabs\Enum\Enum; */ class Result extends Enum { - const none = '*'; - const lost = '0'; - const draw = '0.5'; - const won = '1'; - const absent = '0 FF'; - const wonforfait = '1 FF'; - const adjourned = '0 A'; - const drawadjourned = '0.5 A'; - const wonadjourned = '1 A'; - const bye = '0 Bye'; - const wonbye = '1 Bye'; + const None = '*'; + const Lost = '0'; + const Draw = '0.5'; + const Won = '1'; + const Absent = '0 FF'; + const WonForfait = '1 FF'; + const Adjourned = '0 A'; + const DrawAdjourned = '0.5 A'; + const WonAdjourned = '1 A'; + const Bye = '0 Bye'; + const WonBye = '1 Bye'; } diff --git a/src/Game.php b/src/Game.php index 28ba8e1..0da15af 100644 --- a/src/Game.php +++ b/src/Game.php @@ -29,13 +29,13 @@ use DateTime; class Game { /** @var Pairing | null */ - private $white; + private $White; /** @var Pairing | null */ - private $black; + private $Black; /** @var GameResult | null */ - private $result; + private $Result; /** @var int */ private $Board; @@ -47,8 +47,8 @@ class Game */ public function getResult(): Gameresult { - if (!is_null($this->result)) { - return $this->result; + if (!is_null($this->Result)) { + return $this->Result; } $whiteResult = $this->getWhite()->getResult(); @@ -83,18 +83,18 @@ class Game */ public function getWhite(): ?Pairing { - return $this->white; + return $this->White; } /** * Sets pairing for white player * - * @param Pairing | null $white + * @param Pairing | null $White * @return Game */ - public function setWhite(?Pairing $white): Game + public function setWhite(?Pairing $White): Game { - $this->white = $white; + $this->White = $White; return $this; } @@ -105,30 +105,30 @@ class Game */ public function getBlack(): ?Pairing { - return $this->black; + return $this->Black; } /** * Sets pairing for black player * - * @param Pairing | null $black + * @param Pairing | null $Black * @return Game */ - public function setBlack(?Pairing $black): Game + public function setBlack(?Pairing $Black): Game { - $this->black = $black; + $this->Black = $Black; return $this; } /** * Sets result for game * - * @param Gameresult | null $result + * @param Gameresult | null $Result * @return Game */ - public function setResult(?Gameresult $result): Game + public function setResult(?Gameresult $Result): Game { - $this->result = $result; + $this->Result = $Result; return $this; } diff --git a/src/IOFactory.php b/src/IOFactory.php index c5f97c5..9b3e70e 100644 --- a/src/IOFactory.php +++ b/src/IOFactory.php @@ -33,7 +33,7 @@ abstract class IOFactory * * @var array */ - private static $readers = [ + private static $Readers = [ 'Swar-4' => Readers\Swar4::class, 'Pairtwo-6' => Readers\Pairtwo6::class, 'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical @@ -51,12 +51,12 @@ abstract class IOFactory */ public static function createReader(string $type): ReaderInterface { - if (!isset(self::$readers[$type])) { + if (!isset(self::$Readers[$type])) { throw new LibpairtwoException("Cannot read type $type"); } // create reader class - $readerClass = self::$readers[$type]; + $readerClass = self::$Readers[$type]; $reader = new $readerClass; return $reader; diff --git a/src/Readers/Pairtwo6.php b/src/Readers/Pairtwo6.php index 0055b21..02dafb8 100644 --- a/src/Readers/Pairtwo6.php +++ b/src/Readers/Pairtwo6.php @@ -703,15 +703,15 @@ class Pairtwo6 implements ReaderInterface switch ($this->readData('Int', substr($swscontents, $offset, $length))) { case 255: case 253: - $color = Color::black; + $color = Color::Black; break; case 1: case 3: - $color = Color::white; + $color = Color::White; break; case 0: default: - $color = Color::none; + $color = Color::None; break; } $pairing->setColor(new Color($color)); @@ -720,38 +720,38 @@ class Pairtwo6 implements ReaderInterface $length = 1; switch ($this->readData('Int', substr($swscontents, $offset, $length))) { case 1: - $result = Result::lost; + $result = Result::Lost; break; case 2: - $result = Result::absent; + $result = Result::Absent; break; case 3: - $result = Result::adjourned; + $result = Result::Adjourned; break; case 4: - $result = Result::bye; + $result = Result::Bye; break; case 6: - $result = Result::draw; + $result = Result::Draw; break; case 8: - $result = Result::drawadjourned; + $result = Result::DrawAdjourned; break; case 11: - $result = Result::won; + $result = Result::Won; break; case 12: - $result = Result::wonforfait; + $result = Result::WonForfait; break; case 13: - $result = Result::wonadjourned; + $result = Result::WonAdjourned; break; case 14: - $result = Result::wonbye; + $result = Result::WonBye; break; case 0: default: - $result = Result::none; + $result = Result::None; break; } $pairing->setResult(new Result($result)); diff --git a/src/Readers/Swar4.php b/src/Readers/Swar4.php index 8ad9e54..6d0631a 100644 --- a/src/Readers/Swar4.php +++ b/src/Readers/Swar4.php @@ -37,10 +37,10 @@ class Swar4 implements ReaderInterface private $tournament; /** @var bool|int|DateTime|string[] */ - private $binaryData; + private $BinaryData; /** @var string */ - private $release; + private $Release; /** @var array */ private const CompatibleVersions = ['v4.']; @@ -430,46 +430,46 @@ class Swar4 implements ReaderInterface } switch ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_result')) { case '1000': - $result = Result::lost; + $result = Result::Lost; break; case '01': - $result = Result::absent; + $result = Result::Absent; break; case '0010': - $result = Result::bye; + $result = Result::Bye; break; case '2000': - $result = Result::draw; + $result = Result::Draw; break; case '4000': - $result = Result::won; + $result = Result::Won; break; case '04': - $result = Result::wonforfait; + $result = Result::WonForfait; break; case '40': - $result = Result::wonbye; + $result = Result::WonBye; break; case '00': default: - $result = Result::none; + $result = Result::None; break; } if (array_search($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_table'), [ 16384, 8192 ]) !== false) { - $result = Result::absent; + $result = Result::Absent; } $pairing->setResult(new Result($result)); switch ($this->getTournament()->getBinaryData('Pairing_' . $ptn . '_color')) { case 4294967295: - $color = Color::black; + $color = Color::Black; break; case 1: - $color = Color::white; + $color = Color::White; break; case 0: default: - $color = Color::none; + $color = Color::None; break; } $pairing->setColor(new Color($color)); @@ -571,15 +571,15 @@ class Swar4 implements ReaderInterface */ public function getRelease(): string { - return $this->release; + return $this->Release; } /** - * @param string $release + * @param string $Release */ - public function setRelease(string $release): void + public function setRelease(string $Release): void { - $this->release = $release; + $this->Release = $Release; } /** diff --git a/src/Round.php b/src/Round.php index cc2aa99..910f942 100644 --- a/src/Round.php +++ b/src/Round.php @@ -32,28 +32,28 @@ class Round * * @var DateTime */ - private $date; + private $Date; /** * Array of all games * * @var Game[] */ - private $games = []; + private $Games = []; /** * Number of the round * * @var int */ - private $roundNo; + private $RoundNo; /** * Array of all pairings for this round * * @var Pairing[] */ - private $pairings = []; + private $Pairings = []; /** * Adds a game to the round @@ -94,7 +94,7 @@ class Round $allPairings = $this->getPairings(); $byePairings = []; foreach ($allPairings as $pairing) { - if ($pairing->getResult() == Result::wonbye) { + if ($pairing->getResult() == Result::WonBye) { $byePairings[] = $pairing; } } @@ -112,7 +112,7 @@ class Round $allPairings = $this->getPairings(); $absentPairings = []; foreach ($allPairings as $pairing) { - if ($pairing->getResult() == Result::absent) { + if ($pairing->getResult() == Result::Absent) { $absentPairings[] = $pairing; } } @@ -126,17 +126,17 @@ class Round */ public function getDate(): DateTime { - return $this->date; + return $this->Date; } /** * Sets the date of the round * - * @param DateTime $date + * @param DateTime $Date * @return Round */ - public function setDate(DateTime $date): Round + public function setDate(DateTime $Date): Round { - $this->date = $date; + $this->Date = $Date; return $this; } /** @@ -146,17 +146,17 @@ class Round */ public function getGames(): array { - return $this->games; + return $this->Games; } /** * Sets an array of all games for the round * - * @param Game[] $games + * @param Game[] $Games * @return Round */ - public function setGames(array $games): Round + public function setGames(array $Games): Round { - $this->games = $games; + $this->Games = $Games; return $this; } /** @@ -166,17 +166,17 @@ class Round */ public function getRoundNo(): int { - return $this->roundNo; + return $this->RoundNo; } /** * Sets the round number of the round * - * @param int $roundNo + * @param int $RoundNo * @return Round */ - public function setRoundNo(int $roundNo): Round + public function setRoundNo(int $RoundNo): Round { - $this->roundNo = $roundNo; + $this->RoundNo = $RoundNo; return $this; } /** @@ -186,17 +186,17 @@ class Round */ public function getPairings(): array { - return $this->pairings; + return $this->Pairings; } /** * Sets an array of all pairings for the round * - * @param Pairing[] $pairings + * @param Pairing[] $Pairings * @return Round */ - public function setPairings(array $pairings): Round + public function setPairings(array $Pairings): Round { - $this->pairings = $pairings; + $this->Pairings = $Pairings; return $this; } } diff --git a/src/Tournament.php b/src/Tournament.php index 0a3d8f5..efce818 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -103,7 +103,7 @@ class Tournament private $PriorityId = 'Nation'; /** @var bool|DateTime|int|string[] */ - private $binaryData = []; + private $BinaryData = []; /** * Gets a player by its ID @@ -244,10 +244,10 @@ class Tournament } } $game = new Game(); - if ($color->getValue() == Color::white) { + if ($color->getValue() == Color::White) { $game->setWhite($pairing); $game->setBlack($opponent); - } elseif ($color->getValue() == Color::black) { + } elseif ($color->getValue() == Color::Black) { $game->setWhite($opponent); $game->setBlack($pairing); }