mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-29 09:46:42 +01:00
Updated phpdoc
This commit is contained in:
parent
c6d1afd171
commit
f068a3916d
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@ composer.lock
|
||||
/.php_cs.cache
|
||||
/nbproject/
|
||||
/res/protected/
|
||||
/.idea
|
||||
/.idea
|
||||
doc/api/*
|
||||
|
12
phpdoc.xml
Normal file
12
phpdoc.xml
Normal 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>
|
@ -6,7 +6,7 @@
|
||||
* Time: 14:51
|
||||
*/
|
||||
|
||||
namespace JeroenED\LibPairtwo\Enums;
|
||||
namespace JeroenED\Libpairtwo\Enums;
|
||||
|
||||
use MyCLabs\Enum\Enum;
|
||||
|
||||
|
@ -35,9 +35,9 @@ class Game extends GameModel
|
||||
if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') {
|
||||
$special = ' ' . $blacksplit[1];
|
||||
}
|
||||
$result = $whitesplit[0] . '-' . $blacksplit[0] . $special;
|
||||
$this->setResult(new Gameresult($result));
|
||||
$result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special);
|
||||
$this->setResult($result);
|
||||
|
||||
return new Gameresult($result);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,7 @@
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Gameresult;
|
||||
use JeroenED\LibPairtwo\Player;
|
||||
use JeroenED\LibPairtwo\Pairing;
|
||||
use JeroenED\Libpairtwo\Pairing;
|
||||
|
||||
class Game
|
||||
{
|
||||
|
@ -8,16 +8,25 @@
|
||||
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\LibPairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\LibPairtwo\Player;
|
||||
use JeroenED\Libpairtwo\Player;
|
||||
|
||||
class Pairing
|
||||
{
|
||||
/** @var Player */
|
||||
private $Player;
|
||||
|
||||
/** @var Player */
|
||||
private $Opponent;
|
||||
|
||||
/** @var Color */
|
||||
private $Color;
|
||||
|
||||
/** @var Result */
|
||||
private $Result;
|
||||
|
||||
/** @var int */
|
||||
private $Round;
|
||||
|
||||
/**
|
||||
|
@ -14,23 +14,58 @@ use DateTime;
|
||||
|
||||
class Player
|
||||
{
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var int */
|
||||
private $Rank;
|
||||
|
||||
/** @var int */
|
||||
private $FideId;
|
||||
|
||||
/** @var int */
|
||||
private $ExtraPts;
|
||||
|
||||
/** @var int */
|
||||
private $KbsbElo;
|
||||
|
||||
/** @var DateTime */
|
||||
private $dateofbirth;
|
||||
|
||||
/** @var int */
|
||||
private $KbsbID;
|
||||
|
||||
/** @var float */
|
||||
private $Points;
|
||||
|
||||
/** @var int */
|
||||
private $ClubNr;
|
||||
|
||||
/** @var float */
|
||||
private $ScoreBucholtz;
|
||||
|
||||
/** @var float */
|
||||
private $ScoreAmerican;
|
||||
|
||||
/** @var int */
|
||||
private $FideElo;
|
||||
|
||||
/** @var string */
|
||||
private $Nation;
|
||||
|
||||
/** @var string */
|
||||
private $Category;
|
||||
|
||||
/** @var Title */
|
||||
private $Title;
|
||||
|
||||
/** @var Gender */
|
||||
private $Gender;
|
||||
|
||||
/** @var int */
|
||||
private $NumberOfTies;
|
||||
|
||||
/** @var bool */
|
||||
private $Absent;
|
||||
|
||||
/**
|
||||
@ -236,6 +271,8 @@ class Player
|
||||
}
|
||||
|
||||
/**
|
||||
* example value: BEL
|
||||
*
|
||||
* @param string $Nation
|
||||
*/
|
||||
public function setNation(string $Nation): void
|
||||
|
@ -12,8 +12,11 @@ use DateTime;
|
||||
|
||||
class Round
|
||||
{
|
||||
/** @var DateTime */
|
||||
private $date;
|
||||
private $games;
|
||||
|
||||
/** @var Game[] */
|
||||
private $games = [];
|
||||
|
||||
/** @var int */
|
||||
private $roundNo;
|
||||
|
@ -6,8 +6,13 @@ use JeroenED\Libpairtwo\Tournament;
|
||||
|
||||
class Sws
|
||||
{
|
||||
/** @var string */
|
||||
private $Release;
|
||||
|
||||
/** @var tournament */
|
||||
private $Tournament;
|
||||
|
||||
/** @var bool|DateTime|int|string[] */
|
||||
private $BinaryData;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@
|
||||
namespace JeroenED\Libpairtwo\Models;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\TournamentSystem;
|
||||
use JeroenED\LibPairtwo\Player;
|
||||
use JeroenED\Libpairtwo\Player;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
@ -37,30 +37,70 @@ use DateTime;
|
||||
*/
|
||||
class Tournament
|
||||
{
|
||||
/** @var string */
|
||||
private $Name;
|
||||
|
||||
/** @var string */
|
||||
private $Organiser;
|
||||
|
||||
/** @var int */
|
||||
private $OrganiserClubNo;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserClub;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserPlace;
|
||||
|
||||
/** @var string */
|
||||
private $OrganiserCountry;
|
||||
|
||||
/** @var int */
|
||||
private $FideHomol;
|
||||
|
||||
/** @var DateTime */
|
||||
private $StartDate;
|
||||
|
||||
/** @var DateTime */
|
||||
private $EndDate;
|
||||
|
||||
/** @var string */
|
||||
private $Arbiter;
|
||||
|
||||
/** @var int */
|
||||
private $NoOfRounds;
|
||||
|
||||
/** @var Round[] */
|
||||
private $Rounds;
|
||||
|
||||
/** @var int */
|
||||
private $Participants;
|
||||
|
||||
/** @var string */
|
||||
private $Tempo;
|
||||
|
||||
/** @var int */
|
||||
private $NonRatedElo;
|
||||
|
||||
/** @var TournamentSystem */
|
||||
private $System;
|
||||
|
||||
/** @var string */
|
||||
private $FirstPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $SecondPeriod;
|
||||
|
||||
/** @var string */
|
||||
private $Federation;
|
||||
|
||||
/** @var Player[] */
|
||||
private $Players;
|
||||
|
||||
/** @var int */
|
||||
private $Year;
|
||||
|
||||
/** @var Pairing[] */
|
||||
private $Pairings;
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Time: 11:26
|
||||
*/
|
||||
|
||||
namespace JeroenED\LibPairtwo;
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Models\Player as PlayerModel;
|
||||
|
||||
|
@ -12,7 +12,11 @@ use JeroenED\Libpairtwo\Models\Round as RoundModel;
|
||||
|
||||
class Round extends RoundModel
|
||||
{
|
||||
|
||||
/**
|
||||
* Adds a game to the round
|
||||
*
|
||||
* @param Game $game
|
||||
*/
|
||||
public function addGame(Game $game)
|
||||
{
|
||||
$newarray = $this->getGames();
|
||||
|
39
src/Sws.php
39
src/Sws.php
@ -48,11 +48,10 @@ class Sws extends SwsModel
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* This function reads the sws-file
|
||||
* Reads out $swsfile and returns a Sws class object
|
||||
*
|
||||
* @param string $swsfile
|
||||
* @return SwsModel
|
||||
* @return Sws
|
||||
*/
|
||||
public static function ReadSws(string $swsfile)
|
||||
{
|
||||
@ -60,7 +59,7 @@ class Sws extends SwsModel
|
||||
$swscontents = fread($swshandle, filesize($swsfile));
|
||||
fclose($swshandle);
|
||||
|
||||
$sws = new SwsModel();
|
||||
$sws = new Sws();
|
||||
$offset = 0;
|
||||
|
||||
|
||||
@ -483,10 +482,7 @@ class Sws extends SwsModel
|
||||
|
||||
// Type
|
||||
$length = 4;
|
||||
Switch(self::ReadData('Int', substr($swscontents, $offset, $length))) {
|
||||
case 0:
|
||||
$system = TournamentSystem::Swiss;
|
||||
break;
|
||||
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
|
||||
case 2:
|
||||
$system = TournamentSystem::Closed;
|
||||
break;
|
||||
@ -495,6 +491,11 @@ class Sws extends SwsModel
|
||||
break;
|
||||
case 6:
|
||||
$system = TournamentSystem::Imperial;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$system = TournamentSystem::Swiss;
|
||||
break;
|
||||
}
|
||||
$sws->getTournament()->setSystem(new TournamentSystem($system));
|
||||
$offset += $length;
|
||||
@ -579,9 +580,6 @@ class Sws extends SwsModel
|
||||
|
||||
$length = 1;
|
||||
switch (self::ReadData('Int', substr($swscontents, $offset, $length))) {
|
||||
case 0:
|
||||
$result = Result::none;
|
||||
break;
|
||||
case 1:
|
||||
$result = Result::lost;
|
||||
break;
|
||||
@ -609,9 +607,13 @@ class Sws extends SwsModel
|
||||
case 13:
|
||||
$result = Result::wonadjourned;
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
$result = Result::wonbye;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$result = Result::none;
|
||||
break;
|
||||
}
|
||||
$pairing->setResult(new Result($result));
|
||||
$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 $data
|
||||
* @param mixed $default
|
||||
@ -689,6 +701,9 @@ class Sws extends SwsModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts integer value to a date representation
|
||||
*
|
||||
* @static
|
||||
* @param int $date
|
||||
* @return bool|DateTime
|
||||
*/
|
||||
|
@ -8,15 +8,14 @@
|
||||
|
||||
namespace JeroenED\Libpairtwo;
|
||||
|
||||
use JeroenED\Libpairtwo\Enums\Result;
|
||||
use JeroenED\Libpairtwo\Models\Tournament as TournamentModel;
|
||||
use JeroenED\Libpairtwo\Player;
|
||||
use JeroenED\Libpairtwo\Enums\Color;
|
||||
use JeroenED\Libpairtwo\Enums\Gameresult;
|
||||
|
||||
class Tournament extends TournamentModel
|
||||
{
|
||||
/**
|
||||
* Gets a player by its ID
|
||||
*
|
||||
* @param integer $id
|
||||
* @return Player
|
||||
*/
|
||||
@ -26,6 +25,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a player
|
||||
*
|
||||
* @param 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 Player $player
|
||||
*/
|
||||
@ -47,6 +50,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a round with given Round object
|
||||
*
|
||||
* @param Round $round
|
||||
*/
|
||||
public function addRound(Round $round)
|
||||
@ -57,6 +62,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a round by its number.
|
||||
*
|
||||
* @param int $roundNo
|
||||
* @return Round
|
||||
*/
|
||||
@ -66,6 +73,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a pairing to the tournament
|
||||
*
|
||||
* @param 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
|
||||
{
|
||||
@ -89,7 +98,7 @@ class Tournament extends TournamentModel
|
||||
$round = $pairing->getRound();
|
||||
$color = $pairing->getColor();
|
||||
$opponent = null;
|
||||
foreach($cache as $key=>$cached) {
|
||||
foreach ($cache as $key=>$cached) {
|
||||
if (!is_null($cached)) {
|
||||
if ($cached->getOpponent() == $pairing->getPlayer() && ($cached->getRound() == $pairing->getRound())) {
|
||||
$opponent = $cached;
|
||||
@ -157,6 +166,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a game to the tournament
|
||||
*
|
||||
* @param Game $game
|
||||
* @param int $round
|
||||
*/
|
||||
@ -172,6 +183,8 @@ class Tournament extends TournamentModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ranking of the tournament
|
||||
*
|
||||
* @param bool $americansort
|
||||
* @return Player[]
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user