Updated phpdoc

This commit is contained in:
Jeroen De Meerleer 2019-03-20 17:33:09 +01:00
parent c6d1afd171
commit f068a3916d
14 changed files with 168 additions and 30 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ composer.lock
/.php_cs.cache /.php_cs.cache
/nbproject/ /nbproject/
/res/protected/ /res/protected/
/.idea /.idea
doc/api/*

12
phpdoc.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<parser>
<target>doc/api</target>
</parser>
<transformer>
<target>doc/api</target>
</transformer>
<files>
<directory>src/</directory>
</files>
</phpdoc>

View File

@ -6,7 +6,7 @@
* Time: 14:51 * Time: 14:51
*/ */
namespace JeroenED\LibPairtwo\Enums; namespace JeroenED\Libpairtwo\Enums;
use MyCLabs\Enum\Enum; use MyCLabs\Enum\Enum;

View File

@ -35,9 +35,9 @@ class Game extends GameModel
if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') { if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') {
$special = ' ' . $blacksplit[1]; $special = ' ' . $blacksplit[1];
} }
$result = $whitesplit[0] . '-' . $blacksplit[0] . $special; $result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special);
$this->setResult(new Gameresult($result)); $this->setResult($result);
return new Gameresult($result); return $result;
} }
} }

View File

@ -9,8 +9,7 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Gameresult; use JeroenED\Libpairtwo\Enums\Gameresult;
use JeroenED\LibPairtwo\Player; use JeroenED\Libpairtwo\Pairing;
use JeroenED\LibPairtwo\Pairing;
class Game class Game
{ {

View File

@ -8,16 +8,25 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\LibPairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result; use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\LibPairtwo\Player; use JeroenED\Libpairtwo\Player;
class Pairing class Pairing
{ {
/** @var Player */
private $Player; private $Player;
/** @var Player */
private $Opponent; private $Opponent;
/** @var Color */
private $Color; private $Color;
/** @var Result */
private $Result; private $Result;
/** @var int */
private $Round; private $Round;
/** /**

View File

@ -14,23 +14,58 @@ use DateTime;
class Player class Player
{ {
/** @var string */
private $Name; private $Name;
/** @var int */
private $Rank; private $Rank;
/** @var int */
private $FideId; private $FideId;
/** @var int */
private $ExtraPts; private $ExtraPts;
/** @var int */
private $KbsbElo; private $KbsbElo;
/** @var DateTime */
private $dateofbirth; private $dateofbirth;
/** @var int */
private $KbsbID; private $KbsbID;
/** @var float */
private $Points; private $Points;
/** @var int */
private $ClubNr; private $ClubNr;
/** @var float */
private $ScoreBucholtz; private $ScoreBucholtz;
/** @var float */
private $ScoreAmerican; private $ScoreAmerican;
/** @var int */
private $FideElo; private $FideElo;
/** @var string */
private $Nation; private $Nation;
/** @var string */
private $Category; private $Category;
/** @var Title */
private $Title; private $Title;
/** @var Gender */
private $Gender; private $Gender;
/** @var int */
private $NumberOfTies; private $NumberOfTies;
/** @var bool */
private $Absent; private $Absent;
/** /**
@ -236,6 +271,8 @@ class Player
} }
/** /**
* example value: BEL
*
* @param string $Nation * @param string $Nation
*/ */
public function setNation(string $Nation): void public function setNation(string $Nation): void

View File

@ -12,8 +12,11 @@ use DateTime;
class Round class Round
{ {
/** @var DateTime */
private $date; private $date;
private $games;
/** @var Game[] */
private $games = [];
/** @var int */ /** @var int */
private $roundNo; private $roundNo;

View File

@ -6,8 +6,13 @@ use JeroenED\Libpairtwo\Tournament;
class Sws class Sws
{ {
/** @var string */
private $Release; private $Release;
/** @var tournament */
private $Tournament; private $Tournament;
/** @var bool|DateTime|int|string[] */
private $BinaryData; private $BinaryData;
/** /**

View File

@ -27,7 +27,7 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\TournamentSystem; use JeroenED\Libpairtwo\Enums\TournamentSystem;
use JeroenED\LibPairtwo\Player; use JeroenED\Libpairtwo\Player;
use DateTime; use DateTime;
/** /**
@ -37,30 +37,70 @@ use DateTime;
*/ */
class Tournament class Tournament
{ {
/** @var string */
private $Name; private $Name;
/** @var string */
private $Organiser; private $Organiser;
/** @var int */
private $OrganiserClubNo; private $OrganiserClubNo;
/** @var string */
private $OrganiserClub; private $OrganiserClub;
/** @var string */
private $OrganiserPlace; private $OrganiserPlace;
/** @var string */
private $OrganiserCountry; private $OrganiserCountry;
/** @var int */
private $FideHomol; private $FideHomol;
/** @var DateTime */
private $StartDate; private $StartDate;
/** @var DateTime */
private $EndDate; private $EndDate;
/** @var string */
private $Arbiter; private $Arbiter;
/** @var int */
private $NoOfRounds; private $NoOfRounds;
/** @var Round[] */ /** @var Round[] */
private $Rounds; private $Rounds;
/** @var int */
private $Participants; private $Participants;
/** @var string */
private $Tempo; private $Tempo;
/** @var int */
private $NonRatedElo; private $NonRatedElo;
/** @var TournamentSystem */
private $System; private $System;
/** @var string */
private $FirstPeriod; private $FirstPeriod;
/** @var string */
private $SecondPeriod; private $SecondPeriod;
/** @var string */
private $Federation; private $Federation;
/** @var Player[] */
private $Players; private $Players;
/** @var int */
private $Year; private $Year;
/** @var Pairing[] */
private $Pairings; private $Pairings;
/** /**

View File

@ -6,7 +6,7 @@
* Time: 11:26 * Time: 11:26
*/ */
namespace JeroenED\LibPairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Models\Player as PlayerModel; use JeroenED\Libpairtwo\Models\Player as PlayerModel;

View File

@ -12,7 +12,11 @@ use JeroenED\Libpairtwo\Models\Round as RoundModel;
class Round extends RoundModel class Round extends RoundModel
{ {
/**
* Adds a game to the round
*
* @param Game $game
*/
public function addGame(Game $game) public function addGame(Game $game)
{ {
$newarray = $this->getGames(); $newarray = $this->getGames();

View File

@ -48,11 +48,10 @@ class Sws extends SwsModel
/** /**
* * Reads out $swsfile and returns a Sws class object
* This function reads the sws-file
* *
* @param string $swsfile * @param string $swsfile
* @return SwsModel * @return Sws
*/ */
public static function ReadSws(string $swsfile) public static function ReadSws(string $swsfile)
{ {
@ -60,7 +59,7 @@ class Sws extends SwsModel
$swscontents = fread($swshandle, filesize($swsfile)); $swscontents = fread($swshandle, filesize($swsfile));
fclose($swshandle); fclose($swshandle);
$sws = new SwsModel(); $sws = new Sws();
$offset = 0; $offset = 0;
@ -483,10 +482,7 @@ class Sws extends SwsModel
// Type // Type
$length = 4; $length = 4;
Switch(self::ReadData('Int', substr($swscontents, $offset, $length))) { switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
case 0:
$system = TournamentSystem::Swiss;
break;
case 2: case 2:
$system = TournamentSystem::Closed; $system = TournamentSystem::Closed;
break; break;
@ -495,6 +491,11 @@ class Sws extends SwsModel
break; break;
case 6: case 6:
$system = TournamentSystem::Imperial; $system = TournamentSystem::Imperial;
break;
case 0:
default:
$system = TournamentSystem::Swiss;
break;
} }
$sws->getTournament()->setSystem(new TournamentSystem($system)); $sws->getTournament()->setSystem(new TournamentSystem($system));
$offset += $length; $offset += $length;
@ -579,9 +580,6 @@ class Sws extends SwsModel
$length = 1; $length = 1;
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) { switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
case 0:
$result = Result::none;
break;
case 1: case 1:
$result = Result::lost; $result = Result::lost;
break; break;
@ -609,9 +607,13 @@ class Sws extends SwsModel
case 13: case 13:
$result = Result::wonadjourned; $result = Result::wonadjourned;
break; break;
case 13: case 14:
$result = Result::wonbye; $result = Result::wonbye;
break; break;
case 0:
default:
$result = Result::none;
break;
} }
$pairing->setResult(new Result($result)); $pairing->setResult(new Result($result));
$offset += $length; $offset += $length;
@ -629,6 +631,16 @@ class Sws extends SwsModel
} }
/** /**
* Converts $data to $type and defaults to $default if given
*
* Possible types for $type are:
* * String (UTF-8 String representation of $data. Default: empty string '')
* * Hex (Capitalized Hex Value of $data. Default: 00)
* * Int (Unsigned Integer value of $data Default: 0)
* * Bool (Boolean representation of $data. Default: false)
* * Date (Date representation of $data. Default: 1902/01/01)
*
* @static
* @param string $type * @param string $type
* @param string $data * @param string $data
* @param mixed $default * @param mixed $default
@ -689,6 +701,9 @@ class Sws extends SwsModel
} }
/** /**
* Converts integer value to a date representation
*
* @static
* @param int $date * @param int $date
* @return bool|DateTime * @return bool|DateTime
*/ */

View File

@ -8,15 +8,14 @@
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Models\Tournament as TournamentModel; use JeroenED\Libpairtwo\Models\Tournament as TournamentModel;
use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gameresult;
class Tournament extends TournamentModel class Tournament extends TournamentModel
{ {
/** /**
* Gets a player by its ID
*
* @param integer $id * @param integer $id
* @return Player * @return Player
*/ */
@ -26,6 +25,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Adds a player
*
* @param Player $Player * @param Player $Player
*/ */
public function addPlayer(Player $Player) public function addPlayer(Player $Player)
@ -36,6 +37,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Updates player on id to the given Player object
*
* @param int $id * @param int $id
* @param Player $player * @param Player $player
*/ */
@ -47,6 +50,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Adds a round with given Round object
*
* @param Round $round * @param Round $round
*/ */
public function addRound(Round $round) public function addRound(Round $round)
@ -57,6 +62,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Gets a round by its number.
*
* @param int $roundNo * @param int $roundNo
* @return Round * @return Round
*/ */
@ -66,6 +73,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Adds a pairing to the tournament
*
* @param Pairing $pairing * @param Pairing $pairing
*/ */
public function addPairing(Pairing $pairing) public function addPairing(Pairing $pairing)
@ -76,7 +85,7 @@ class Tournament extends TournamentModel
} }
/** /**
* This function converts the array of pairings into rounds * Converts pairings into games with a black and white player
*/ */
public function pairingsToRounds(): void public function pairingsToRounds(): void
{ {
@ -89,7 +98,7 @@ class Tournament extends TournamentModel
$round = $pairing->getRound(); $round = $pairing->getRound();
$color = $pairing->getColor(); $color = $pairing->getColor();
$opponent = null; $opponent = null;
foreach($cache as $key=>$cached) { foreach ($cache as $key=>$cached) {
if (!is_null($cached)) { if (!is_null($cached)) {
if ($cached->getOpponent() == $pairing->getPlayer() && ($cached->getRound() == $pairing->getRound())) { if ($cached->getOpponent() == $pairing->getPlayer() && ($cached->getRound() == $pairing->getRound())) {
$opponent = $cached; $opponent = $cached;
@ -157,6 +166,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Adds a game to the tournament
*
* @param Game $game * @param Game $game
* @param int $round * @param int $round
*/ */
@ -172,6 +183,8 @@ class Tournament extends TournamentModel
} }
/** /**
* Gets the ranking of the tournament
*
* @param bool $americansort * @param bool $americansort
* @return Player[] * @return Player[]
*/ */