Skip to content

Commit da72e67

Browse files
committed
Add php doc
1 parent 9b13d7b commit da72e67

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

src/Simonsator/PartyAndFriends/PAFPlayer.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,39 @@ class PAFPlayer
88
private string $name;
99
private int $id;
1010

11+
/**
12+
* @param string $pUUID
13+
* @param string $pName
14+
* @param int $pID
15+
*
16+
* This constructor should only be called from within the library. It should never be created by an external class.
17+
*/
1118
public function __construct(string $pUUID, string $pName, int $pID)
1219
{
1320
$this->uniqueID = $pUUID;
1421
$this->name = $pName;
1522
$this->id = $pID;
1623
}
1724

25+
/**
26+
* @return string The name of the player (not the display name)
27+
*/
1828
public function getName(): string
1929
{
2030
return $this->name;
2131
}
2232

33+
/**
34+
* @return string The unique id of the player
35+
*/
2336
public function getUniqueID(): string
2437
{
2538
return $this->uniqueID;
2639
}
2740

41+
/**
42+
* @return PAFPlayer[] Returns an array with all friends of the player
43+
*/
2844
public function getFriends(): array
2945
{
3046
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
@@ -50,6 +66,9 @@ public function getFriends(): array
5066
return [];
5167
}
5268

69+
/**
70+
* @return PAFPlayer[] Returns an array with containing all players that have sent a friend request to the player, which have not yet been denied or accepted
71+
*/
5372
public function getFriendRequests(): array
5473
{
5574
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
@@ -71,6 +90,9 @@ public function getFriendRequests(): array
7190
return [];
7291
}
7392

93+
/**
94+
* @return PAFPlayer[] Returns an array with all open friend requests this player sent to other players
95+
*/
7496
public function getSentFriendRequests(): array
7597
{
7698
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
@@ -92,6 +114,17 @@ public function getSentFriendRequests(): array
92114
return [];
93115
}
94116

117+
/**
118+
* @param int $pSettingsID The id of the setting. Extensions might add more settings, but by default, the plugin has the following settings:
119+
* 0 = Friend Request Setting
120+
* 1 = Party Invite Setting
121+
* 2 = PM Setting
122+
* 3 = Offline Setting
123+
* 4 = Jump Setting
124+
* 6 = Hide Setting
125+
*
126+
* @return int Returns the value of the setting
127+
*/
95128
public function getSettingsWorth(int $pSettingsID): int
96129
{
97130
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
@@ -104,6 +137,10 @@ public function getSettingsWorth(int $pSettingsID): int
104137
return 0;
105138
}
106139

140+
/**
141+
* @param PAFPlayer $player The player which should be the new friend of this player
142+
* @return void
143+
*/
107144
public function addFriend(PAFPlayer $player)
108145
{
109146
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
@@ -112,12 +149,19 @@ public function addFriend(PAFPlayer $player)
112149
$stmt->execute();
113150
}
114151

152+
/**
153+
* @return int Returns the id of the player as used in the party and friends database
154+
*/
115155
public function getID(): int
116156
{
117157
return $this->id;
118158
}
119159

120-
public function sendFriendRequest(PAFPlayer $player)
160+
/**
161+
* @param PAFPlayer $player The player which should receive a friend request from this player
162+
* @return void
163+
*/
164+
public function sendFriendRequest(PAFPlayer $player): void
121165
{
122166
$stmt = PAFPlayerManager::getInstance()->getConnection()->prepare(
123167
"INSERT INTO {PAFPlayerManager::getInstance()->getTablePrefix()}friend_assignment

src/Simonsator/PartyAndFriends/PAFPlayerManager.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
/**
3-
* User: Simonsator
4-
* Date: 10.02.17
5-
* Time: 14:28
6-
*/
72

83
namespace Simonsator\PartyAndFriends;
94

@@ -19,18 +14,29 @@ class PAFPlayerManager
1914
private PDO $connection;
2015
private string $tablePrefix;
2116

17+
/**
18+
* @param PDO $pPod The connection to the MySQL database
19+
* @param string $tablePrefix The prefix of the tables as set in the Party and Friends config
20+
*/
2221
public function __construct(PDO $pPod, string $tablePrefix)
2322
{
2423
self::$instance = $this;
2524
$this->connection = $pPod;
2625
$this->tablePrefix = $tablePrefix;
2726
}
2827

28+
/**
29+
* @return PAFPlayerManager Returns the instance of the PAFPlayerManager. Make sure that it was initialized using the constructor before using this method
30+
*/
2931
public static function getInstance(): PAFPlayerManager
3032
{
3133
return self::$instance;
3234
}
3335

36+
/**
37+
* @param string $pUUID The uuid of the player
38+
* @return PAFPlayer|null Returns the player if they ever joined the server or null if they did never join this server
39+
*/
3440
public function getPlayerByUUID(string $pUUID): ?PAFPlayer
3541
{
3642
$stmt = $this->connection->prepare(
@@ -47,14 +53,18 @@ public function getPlayerByUUID(string $pUUID): ?PAFPlayer
4753
}
4854

4955
/**
50-
* @return String
56+
* @return String Returns the prefix of the tables as set in the Party and Friends config
5157
*/
5258
public function getTablePrefix(): string
5359
{
5460
return $this->tablePrefix;
5561
}
5662

57-
public function getPlayerByID($pID): ?PAFPlayer
63+
/**
64+
* @param int $pID The id of the player as used in the party and friends database
65+
* @return PAFPlayer|null Returns the corresponding player if the id belongs to a player or null if the id does not belong to a player
66+
*/
67+
public function getPlayerByID(int $pID): ?PAFPlayer
5868
{
5969
$stmt = $this->connection->prepare(
6070
"SELECT player_id, player_uuid, player_name
@@ -74,7 +84,11 @@ public function getConnection(): PDO
7484
return $this->connection;
7585
}
7686

77-
public function getPlayerByName($pPlayerName): ?PAFPlayer
87+
/**
88+
* @param string $pPlayerName The name of the player
89+
* @return PAFPlayer|null Returns the player if they ever joined the server or null if they did never join this server
90+
*/
91+
public function getPlayerByName(string $pPlayerName): ?PAFPlayer
7892
{
7993
$stmt = $this->connection->prepare(
8094
"SELECT player_id, player_uuid, player_name

0 commit comments

Comments
 (0)