Updated phpdoc

This commit is contained in:
Jeroen De Meerleer 2019-02-11 17:27:26 +01:00
parent b6c72e9021
commit 64e47ff606
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
6 changed files with 159 additions and 154 deletions

View File

@ -11,7 +11,6 @@ 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;
use phpDocumentor\Reflection\Types\Integer;
class Pairing class Pairing
{ {
@ -38,7 +37,7 @@ class Pairing
} }
/** /**
* @return mixed * @return Player
*/ */
public function getOpponent(): Player public function getOpponent(): Player
{ {
@ -46,7 +45,7 @@ class Pairing
} }
/** /**
* @param mixed $Opponent * @param Player $Opponent
*/ */
public function setOpponent(Player $Opponent): void public function setOpponent(Player $Opponent): void
{ {

View File

@ -9,7 +9,6 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\Title; use JeroenED\Libpairtwo\Enums\Title;
use JeroenED\Libpairtwo\Enums\Sex; use JeroenED\Libpairtwo\Enums\Sex;
use DateTime; use DateTime;
class Player class Player
@ -36,7 +35,7 @@ class Player
/** /**
* @return string * @return string
*/ */
public function getName() public function getName(): string
{ {
return $this->Name; return $this->Name;
} }
@ -50,73 +49,73 @@ class Player
} }
/** /**
* @return integer * @return int
*/ */
public function getRank() public function getRank(): int
{ {
return $this->Rank; return $this->Rank;
} }
/** /**
* @param integer $Rank * @param int $Rank
*/ */
public function setRank($Rank): void public function setRank(int $Rank): void
{ {
$this->Rank = $Rank; $this->Rank = $Rank;
} }
/** /**
* @return integer * @return int
*/ */
public function getFideId() public function getFideId(): int
{ {
return $this->FideId; return $this->FideId;
} }
/** /**
* @param integer $FideId * @param int $FideId
*/ */
public function setFideId($FideId): void public function setFideId(int $FideId): void
{ {
$this->FideId = $FideId; $this->FideId = $FideId;
} }
/** /**
* @return integer * @return int
*/ */
public function getExtraPts() public function getExtraPts(): int
{ {
return $this->ExtraPts; return $this->ExtraPts;
} }
/** /**
* @param integer $ExtraPts * @param int $ExtraPts
*/ */
public function setExtraPts($ExtraPts): void public function setExtraPts(int $ExtraPts): void
{ {
$this->ExtraPts = $ExtraPts; $this->ExtraPts = $ExtraPts;
} }
/** /**
* @return integer * @return int
*/ */
public function getKbsbElo() public function getKbsbElo(): int
{ {
return $this->KbsbElo; return $this->KbsbElo;
} }
/** /**
* @param integer $KbsbElo * @param int $KbsbElo
*/ */
public function setKbsbElo($KbsbElo): void public function setKbsbElo(int $KbsbElo): void
{ {
$this->KbsbElo = $KbsbElo; $this->KbsbElo = $KbsbElo;
} }
/** /**
* @return integer * @return DateTime
*/ */
public function getDateofbirth() public function getDateofbirth(): DateTime
{ {
return $this->dateofbirth; return $this->dateofbirth;
} }
@ -130,101 +129,97 @@ class Player
} }
/** /**
* @return integer * @return int
*/ */
public function getKbsbID() public function getKbsbID(): int
{ {
return $this->KbsbID; return $this->KbsbID;
} }
/** /**
* @param integer $KbsbID * @param int $KbsbID
*/ */
public function setKbsbID($KbsbID): void public function setKbsbID(int $KbsbID): void
{ {
$this->KbsbID = $KbsbID; $this->KbsbID = $KbsbID;
} }
/** /**
* Note: SWS file returns points * 2 to circumvent use of floating point * @return float
*
* @return integer
*/ */
public function getPoints() public function getPoints(): float
{ {
return $this->Points; return $this->Points;
} }
/** /**
* Note: SWS file returns points * 2 to circumvent use of floating point * @param float $Points
*
* @param integer $Points
*/ */
public function setPoints($Points): void public function setPoints(float $Points): void
{ {
$this->Points = $Points; $this->Points = $Points;
} }
/** /**
* @return integer * @return int
*/ */
public function getClubNr() public function getClubNr(): int
{ {
return $this->ClubNr; return $this->ClubNr;
} }
/** /**
* @param integer $ClubNr * @param int $ClubNr
*/ */
public function setClubNr($ClubNr): void public function setClubNr(int $ClubNr): void
{ {
$this->ClubNr = $ClubNr; $this->ClubNr = $ClubNr;
} }
/** /**
* @return integer * @return float
*/ */
public function getScoreBucholtz() public function getScoreBucholtz(): float
{ {
return $this->ScoreBucholtz; return $this->ScoreBucholtz;
} }
/** /**
* @param integer $ScoreBucholtz * @param float $ScoreBucholtz
*/ */
public function setScoreBucholtz($ScoreBucholtz): void public function setScoreBucholtz(float $ScoreBucholtz): void
{ {
$this->ScoreBucholtz = $ScoreBucholtz; $this->ScoreBucholtz = $ScoreBucholtz;
} }
/** /**
* @return integer * @return int
*/ */
public function getScoreAmerican() public function getScoreAmerican(): int
{ {
return $this->ScoreAmerican; return $this->ScoreAmerican;
} }
/** /**
* @param integer $ScoreAmerican * @param int $ScoreAmerican
*/ */
public function setScoreAmerican($ScoreAmerican): void public function setScoreAmerican(int $ScoreAmerican): void
{ {
$this->ScoreAmerican = $ScoreAmerican; $this->ScoreAmerican = $ScoreAmerican;
} }
/** /**
* @return integer * @return int
*/ */
public function getFideElo() public function getFideElo(): int
{ {
return $this->FideElo; return $this->FideElo;
} }
/** /**
* @param integer $FideElo * @param int $FideElo
*/ */
public function setFideElo($FideElo): void public function setFideElo(int $FideElo): void
{ {
$this->FideElo = $FideElo; $this->FideElo = $FideElo;
} }
@ -232,9 +227,9 @@ class Player
/** /**
* example value: BEL * example value: BEL
* *
* @return String * @return string
*/ */
public function getNation() public function getNation(): string
{ {
return $this->Nation; return $this->Nation;
} }
@ -242,7 +237,7 @@ class Player
/** /**
* @param string $Nation * @param string $Nation
*/ */
public function setNation($Nation): void public function setNation(string $Nation): void
{ {
$this->Nation = $Nation; $this->Nation = $Nation;
} }
@ -250,7 +245,7 @@ class Player
/** /**
* @return string * @return string
*/ */
public function getCategory() public function getCategory(): string
{ {
return $this->Category; return $this->Category;
} }
@ -258,15 +253,15 @@ class Player
/** /**
* @param string $Category * @param string $Category
*/ */
public function setCategory($Category): void public function setCategory(string $Category): void
{ {
$this->Category = $Category; $this->Category = $Category;
} }
/** /**
* @return FideTitle * @return Title
*/ */
public function getTitle() public function getTitle(): Title
{ {
return $this->Title; return $this->Title;
} }
@ -274,55 +269,55 @@ class Player
/** /**
* @param Title $Title * @param Title $Title
*/ */
public function setTitle($Title): void public function setTitle(Title $Title): void
{ {
$this->Title = $Title; $this->Title = $Title;
} }
/** /**
* @return mixed * @return Sex
*/ */
public function getSex() public function getSex(): Sex
{ {
return $this->Sex; return $this->Sex;
} }
/** /**
* @param mixed $Sex * @param Sex $Sex
*/ */
public function setSex($Sex): void public function setSex(Sex $Sex): void
{ {
$this->Sex = $Sex; $this->Sex = $Sex;
} }
/** /**
* @return mixed * @return int
*/ */
public function getNumberOfTies() public function getNumberOfTies(): int
{ {
return $this->NumberOfTies; return $this->NumberOfTies;
} }
/** /**
* @param mixed $NumberOfTies * @param int $NumberOfTies
*/ */
public function setNumberOfTies($NumberOfTies): void public function setNumberOfTies(int $NumberOfTies): void
{ {
$this->NumberOfTies = $NumberOfTies; $this->NumberOfTies = $NumberOfTies;
} }
/** /**
* @return mixed * @return bool
*/ */
public function getAbsent() public function getAbsent(): bool
{ {
return $this->Absent; return $this->Absent;
} }
/** /**
* @param mixed $Absent * @param bool $Absent
*/ */
public function setAbsent($Absent): void public function setAbsent(bool $Absent): void
{ {
$this->Absent = $Absent; $this->Absent = $Absent;
} }

View File

@ -2,6 +2,8 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Tournament;
class Sws class Sws
{ {
private $Release; private $Release;
@ -11,7 +13,7 @@ class Sws
/** /**
* @return String * @return String
*/ */
public function getRelease() public function getRelease(): string
{ {
return $this->Release; return $this->Release;
} }
@ -19,21 +21,21 @@ class Sws
/** /**
* @param String $Release * @param String $Release
*/ */
public function setRelease(String $Release): void public function setRelease(string $Release): void
{ {
$this->Release = $Release; $this->Release = $Release;
} }
/** /**
* @return \JeroenED\Libpairtwo\Tournament * @return Tournament
*/ */
public function getTournament() public function getTournament(): Tournament
{ {
return $this->Tournament; return $this->Tournament;
} }
/** /**
* @param \JeroenED\Libpairtwo\Tournament $Tournament * @param Tournament $Tournament
*/ */
public function setTournament(Tournament $Tournament): void public function setTournament(Tournament $Tournament): void
{ {
@ -46,7 +48,7 @@ class Sws
* @param string * @param string
* @return string * @return string
*/ */
public function getBinaryData(String $key) public function getBinaryData(string $key)
{ {
return $this->BinaryData[$key]; return $this->BinaryData[$key];
} }
@ -55,9 +57,9 @@ class Sws
* Sets binary data * Sets binary data
* *
* @param string * @param string
* @param string * @param mixed
*/ */
public function setBinaryData(String $key, String $data): void public function setBinaryData(string $key, $data): void
{ {
$this->BinaryData[$key] = $data; $this->BinaryData[$key] = $data;
} }

View File

@ -26,6 +26,7 @@
namespace JeroenED\Libpairtwo\Models; namespace JeroenED\Libpairtwo\Models;
use JeroenED\Libpairtwo\Enums\TournamentSystem; use JeroenED\Libpairtwo\Enums\TournamentSystem;
use DateTime;
/** /**
@ -60,7 +61,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getName() public function getName(): string
{ {
return $this->Name; return $this->Name;
} }
@ -68,7 +69,7 @@ class Tournament
/** /**
* @param string $Name * @param string $Name
*/ */
public function setName($Name): void public function setName(string $Name): void
{ {
$this->Name = $Name; $this->Name = $Name;
} }
@ -76,7 +77,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getOrganiser() public function getOrganiser(): string
{ {
return $this->Organiser; return $this->Organiser;
} }
@ -84,39 +85,39 @@ class Tournament
/** /**
* @param string $Organiser * @param string $Organiser
*/ */
public function setOrganiser($Organiser): void public function setOrganiser(string $Organiser): void
{ {
$this->Organiser = $Organiser; $this->Organiser = $Organiser;
} }
/** /**
* @return String * @return string
*/ */
public function getOrganiserClub() public function getOrganiserClub(): string
{ {
return $this->OrganiserClub; return $this->OrganiserClub;
} }
/** /**
* @param String $OrganiserClub * @param string $OrganiserClub
*/ */
public function setOrganiserClub($OrganiserClub): void public function setOrganiserClub(string $OrganiserClub): void
{ {
$this->OrganiserClub = $OrganiserClub; $this->OrganiserClub = $OrganiserClub;
} }
/** /**
* @return integer * @return int
*/ */
public function getOrganiserClubNo() public function getOrganiserClubNo(): int
{ {
return $this->OrganiserClubNo; return $this->OrganiserClubNo;
} }
/** /**
* @param integer $OrganiserClubno * @param int $OrganiserClubNo
*/ */
public function setOrganiserClubNo($OrganiserClubNo): void public function setOrganiserClubNo(int $OrganiserClubNo): void
{ {
$this->OrganiserClubNo = $OrganiserClubNo; $this->OrganiserClubNo = $OrganiserClubNo;
} }
@ -124,7 +125,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getOrganiserPlace() public function getOrganiserPlace(): string
{ {
return $this->OrganiserPlace; return $this->OrganiserPlace;
} }
@ -132,7 +133,7 @@ class Tournament
/** /**
* @param string $OrganiserPlace * @param string $OrganiserPlace
*/ */
public function setOrganiserPlace($OrganiserPlace): void public function setOrganiserPlace(string $OrganiserPlace): void
{ {
$this->OrganiserPlace = $OrganiserPlace; $this->OrganiserPlace = $OrganiserPlace;
} }
@ -140,7 +141,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getOrganiserCountry() public function getOrganiserCountry(): string
{ {
return $this->OrganiserCountry; return $this->OrganiserCountry;
} }
@ -148,55 +149,55 @@ class Tournament
/** /**
* @param string $OrganiserCountry * @param string $OrganiserCountry
*/ */
public function setOrganiserCountry($OrganiserCountry): void public function setOrganiserCountry(string $OrganiserCountry): void
{ {
$this->OrganiserCountry = $OrganiserCountry; $this->OrganiserCountry = $OrganiserCountry;
} }
/** /**
* @return integer * @return int
*/ */
public function getFideHomol() public function getFideHomol(): int
{ {
return $this->FideHomol; return $this->FideHomol;
} }
/** /**
* @param integer $FideHomol * @param int $FideHomol
*/ */
public function setFideHomol($FideHomol): void public function setFideHomol(int $FideHomol): void
{ {
$this->FideHomol = $FideHomol; $this->FideHomol = $FideHomol;
} }
/** /**
* @return integer * @return DateTime
*/ */
public function getStartDate() public function getStartDate(): DateTime
{ {
return $this->StartDate; return $this->StartDate;
} }
/** /**
* @param integer $StartDate * @param DateTime $StartDate
*/ */
public function setStartDate($StartDate): void public function setStartDate(DateTime $StartDate): void
{ {
$this->StartDate = $StartDate; $this->StartDate = $StartDate;
} }
/** /**
* @return integer * @return DateTime
*/ */
public function getEndDate() public function getEndDate(): DateTime
{ {
return $this->EndDate; return $this->EndDate;
} }
/** /**
* @param integer$EndDate * @param DateTime $EndDate
*/ */
public function setEndDate($EndDate): void public function setEndDate(DateTime $EndDate): void
{ {
$this->EndDate = $EndDate; $this->EndDate = $EndDate;
} }
@ -204,7 +205,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getArbiter() public function getArbiter(): string
{ {
return $this->Arbiter; return $this->Arbiter;
} }
@ -212,39 +213,39 @@ class Tournament
/** /**
* @param string $Arbiter * @param string $Arbiter
*/ */
public function setArbiter($Arbiter): void public function setArbiter(string $Arbiter): void
{ {
$this->Arbiter = $Arbiter; $this->Arbiter = $Arbiter;
} }
/** /**
* @return integer * @return int
*/ */
public function getRounds() public function getRounds(): int
{ {
return $this->Rounds; return $this->Rounds;
} }
/** /**
* @param integer $Rounds * @param int $Rounds
*/ */
public function setRounds($Rounds): void public function setRounds(int $Rounds): void
{ {
$this->Rounds = $Rounds; $this->Rounds = $Rounds;
} }
/** /**
* @return integer * @return int
*/ */
public function getParticipants() public function getParticipants(): int
{ {
return $this->Participants; return $this->Participants;
} }
/** /**
* @param integer $Participants * @param int $Participants
*/ */
public function setParticipants($Participants): void public function setParticipants(int $Participants): void
{ {
$this->Participants = $Participants; $this->Participants = $Participants;
} }
@ -252,7 +253,7 @@ class Tournament
/** /**
* @return string * @return string
*/ */
public function getTempo() public function getTempo(): string
{ {
return $this->Tempo; return $this->Tempo;
} }
@ -260,23 +261,23 @@ class Tournament
/** /**
* @param string $Tempo * @param string $Tempo
*/ */
public function setTempo($Tempo): void public function setTempo(string $Tempo): void
{ {
$this->Tempo = $Tempo; $this->Tempo = $Tempo;
} }
/** /**
* @return integer * @return int
*/ */
public function getNonRatedElo() public function getNonRatedElo(): int
{ {
return $this->NonRatedElo; return $this->NonRatedElo;
} }
/** /**
* @param integer $NonRatedElo * @param int $NonRatedElo
*/ */
public function setNonRatedElo($NonRatedElo): void public function setNonRatedElo(int $NonRatedElo): void
{ {
$this->NonRatedElo = $NonRatedElo; $this->NonRatedElo = $NonRatedElo;
} }
@ -284,7 +285,7 @@ class Tournament
/** /**
* @return TournamentSystem * @return TournamentSystem
*/ */
public function getSystem() public function getSystem(): TournamentSystem
{ {
return $this->System; return $this->System;
} }
@ -292,61 +293,61 @@ class Tournament
/** /**
* @param TournamentSystem $System * @param TournamentSystem $System
*/ */
public function setSystem($System): void public function setSystem(TournamentSystem $System): void
{ {
$this->System = $System; $this->System = $System;
} }
/** /**
* @return String * @return string
*/ */
public function getFirstPeriod() public function getFirstPeriod(): string
{ {
return $this->FirstPeriod; return $this->FirstPeriod;
} }
/** /**
* @param String $FirstPeriod * @param string $FirstPeriod
*/ */
public function setFirstPeriod($FirstPeriod): void public function setFirstPeriod(string $FirstPeriod): void
{ {
$this->FirstPeriod = $FirstPeriod; $this->FirstPeriod = $FirstPeriod;
} }
/** /**
* @return String * @return string
*/ */
public function getSecondPeriod() public function getSecondPeriod(): string
{ {
return $this->SecondPeriod; return $this->SecondPeriod;
} }
/** /**
* @param String $SecondPeriod * @param string $SecondPeriod
*/ */
public function setSecondPeriod($SecondPeriod): void public function setSecondPeriod(string $SecondPeriod): void
{ {
$this->SecondPeriod = $SecondPeriod; $this->SecondPeriod = $SecondPeriod;
} }
/** /**
* @return String * @return string
*/ */
public function getFederation() public function getFederation(): string
{ {
return $this->Federation; return $this->Federation;
} }
/** /**
* @param String $Federation * @param string $Federation
*/ */
public function setFederation($Federation): void public function setFederation(string $Federation): void
{ {
$this->Federation = $Federation; $this->Federation = $Federation;
} }
/** /**
* @return array * @return Player[]
*/ */
public function getPlayers() public function getPlayers()
{ {
@ -354,7 +355,7 @@ class Tournament
} }
/** /**
* @param array $Players * @param Player[] $Players
*/ */
public function setPlayers($Players): void public function setPlayers($Players): void
{ {
@ -362,17 +363,17 @@ class Tournament
} }
/** /**
* @return mixed * @return int
*/ */
public function getYear() public function getYear(): int
{ {
return $this->Year; return $this->Year;
} }
/** /**
* @param mixed $Year * @param int $Year
*/ */
public function setYear($Year): void public function setYear(int $Year): void
{ {
$this->Year = $Year; $this->Year = $Year;
} }

View File

@ -32,6 +32,7 @@ use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Result; use JeroenED\Libpairtwo\Enums\Result;
use JeroenED\Libpairtwo\Models\Sws as SwsModel; use JeroenED\Libpairtwo\Models\Sws as SwsModel;
use JeroenED\Libpairtwo\Enums\TournamentSystem; use JeroenED\Libpairtwo\Enums\TournamentSystem;
use DateTime;
/** /**
* This class reads a SWS file * This class reads a SWS file
@ -47,6 +48,9 @@ class Sws extends SwsModel
/** /**
*
* This function reads the sws-file
*
* @param string $swsfile * @param string $swsfile
* @return SwsModel * @return SwsModel
*/ */
@ -307,7 +311,7 @@ class Sws extends SwsModel
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$player->setAbsent(self::ReadData('Int', substr($swscontents, $offset, $length))); $player->setAbsent(self::ReadData('Bool', substr($swscontents, $offset, $length)));
$offset += $length; $offset += $length;
$length = 1; $length = 1;
@ -505,11 +509,11 @@ class Sws extends SwsModel
} }
/** /**
* @param String $type * @param string $type
* @param String $data * @param string $data
* @return array|bool|\DateTime|float|int|string * @return bool|DateTime|int|string
*/ */
private static function ReadData(String $type, String $data) private static function ReadData(string $type, string $data)
{ {
switch ($type) { switch ($type) {
case 'String': case 'String':
@ -517,6 +521,7 @@ class Sws extends SwsModel
break; break;
case 'Hex': case 'Hex':
case 'Int': case 'Int':
case 'Bool':
case 'Date': case 'Date':
$hex = implode(unpack("H*", $data)); $hex = implode(unpack("H*", $data));
$hex = array_reverse(str_split($hex, 2)); $hex = array_reverse(str_split($hex, 2));
@ -537,6 +542,8 @@ class Sws extends SwsModel
return hexdec($hex); return hexdec($hex);
} elseif ($type == 'Date') { } elseif ($type == 'Date') {
return self::UIntToTimestamp(hexdec($hex)); return self::UIntToTimestamp(hexdec($hex));
} elseif ($type == 'Bool') {
return ($hex == "01") ? true : false;
} }
break; break;
default: default:
@ -548,10 +555,10 @@ class Sws extends SwsModel
} }
/** /**
* @param $date * @param int $date
* @return bool|\DateTime * @return bool|DateTime
*/ */
private static function UIntToTimestamp($date) private static function UIntToTimestamp(int $date)
{ {
$curyear = date('Y'); $curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET; $yearoffset = $curyear - self::PT_PASTOFFSET;
@ -575,6 +582,6 @@ class Sws extends SwsModel
$format = 'm/d/Y'; $format = 'm/d/Y';
return \DateTime::createFromFormat($format, $concat); return DateTime::createFromFormat($format, $concat);
} }
} }

View File

@ -53,5 +53,6 @@ echo "KBSB Elo P3: " . $sws->getTournament()->getPlayerById(2)->getKbsbElo() .
echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL; echo "Name P1: " . $sws->getTournament()->getPlayerById(0)->getName() . PHP_EOL;
echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL; echo "Name P2: " . $sws->getTournament()->getPlayerById(1)->getName() . PHP_EOL;
echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL; echo "Name P3: " . $sws->getTournament()->getPlayerById(2)->getName() . PHP_EOL;
//echo $sws->getBinaryData("Tournament"); echo "Absent P1: " . $sws->getTournament()->getPlayerById(0)->getAbsent() . PHP_EOL;
//echo $sws->getBinaryData("Players");*/ echo "Absent P2: " . $sws->getTournament()->getPlayerById(1)->getAbsent() . PHP_EOL;
echo "Absent P3: " . $sws->getTournament()->getPlayerById(2)->getAbsent() . PHP_EOL;