|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class CoC_Member |
|
4
|
|
|
{ |
|
5
|
|
|
protected $memberObj; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Constructor of CoC_Member |
|
9
|
|
|
* |
|
10
|
|
|
* @param $memberObj, obtained by Clan.class.php |
|
11
|
|
|
*/ |
|
12
|
|
|
public function __construct($memberObj) |
|
13
|
|
|
{ |
|
14
|
|
|
$this->memberObj = $memberObj; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Gets the members tag (id) |
|
19
|
|
|
* |
|
20
|
|
|
* @return string, tag |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getTag() |
|
23
|
|
|
{ |
|
24
|
|
|
return $this->memberObj->tag; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Gets the members name |
|
29
|
|
|
* |
|
30
|
|
|
* @return string, name |
|
31
|
|
|
*/ |
|
32
|
|
|
public function getName() |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->memberObj->name; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Gets the members role ("member", "admin", "coLeader", "leader") |
|
39
|
|
|
* |
|
40
|
|
|
* @return string, role |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getRole() |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->memberObj->role; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Gets the members level |
|
49
|
|
|
* |
|
50
|
|
|
* @return int, level |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getLevel() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->memberObj->expLevel; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Gets the members league ID |
|
59
|
|
|
* |
|
60
|
|
|
* @return int, league ID |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getLeagueId() |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->memberObj->league->id; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Gets the members league |
|
69
|
|
|
* |
|
70
|
|
|
* @return stdClass |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getLeague() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->memberObj->league; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Gets the members trophy-count |
|
79
|
|
|
* |
|
80
|
|
|
* @return int, trophies |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getTrophies() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->memberObj->trophies; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Gets the members rank inside the clan-ranklist |
|
89
|
|
|
* |
|
90
|
|
|
* @return int, rank |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getClanRank() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->memberObj->clanRank; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Gets the members previous rank inside the clan-ranklist |
|
99
|
|
|
* |
|
100
|
|
|
* @return int, rank |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getPreviousClanRank() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->memberObj->previousClanRank; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Gets the amount of donations done by the member |
|
109
|
|
|
* |
|
110
|
|
|
* @return int, donations |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getDonations() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->memberObj->donations; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Gets the amount of donations received by the member |
|
119
|
|
|
* |
|
120
|
|
|
* @return int, donations |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getDonationsReceived() |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->memberObj->donationsReceived; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Gets the donation ratio of the member |
|
129
|
|
|
* |
|
130
|
|
|
* @return int, ratio |
|
131
|
|
|
*/ |
|
132
|
|
|
public function getDonationsRatio() |
|
133
|
|
|
{ |
|
134
|
|
|
return round($this->memberObj->donations / (float) max($this->memberObj->donationsReceived, 1), 2); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
?> |
|
|
|
|
|
|
139
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.