|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class to get information about Clans. This class uses the data provided by the API.class.php |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
class CoC_Clan |
|
8
|
|
|
{ |
|
9
|
|
|
protected $api; |
|
10
|
|
|
protected $tag; |
|
11
|
|
|
protected $clan = NULL; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Constructor of CoC_Clan |
|
15
|
|
|
* Either pass the clan tag or a stdClass containing all clan information. |
|
16
|
|
|
* |
|
17
|
|
|
* @param $tagOrClass |
|
18
|
|
|
* @param (optional) $isTag |
|
|
|
|
|
|
19
|
|
|
*/ |
|
20
|
|
|
public function __construct($tagOrClass) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->api = new ClashOfClans(); |
|
23
|
|
|
if(is_string($tagOrClass)) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->tag = $tagOrClass; |
|
26
|
|
|
$this->getClan(); |
|
27
|
|
|
} |
|
28
|
|
|
else |
|
29
|
|
|
{ |
|
30
|
|
|
$this->clan = $tagOrClass; |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
protected function getClan() |
|
35
|
|
|
{ |
|
36
|
|
|
if($this->clan == NULL) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->clan = $this->api->getClanByTag($this->tag); |
|
39
|
|
|
} |
|
40
|
|
|
return $this->clan; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Gets the clantag |
|
45
|
|
|
* |
|
46
|
|
|
* @return string, clantag |
|
|
|
|
|
|
47
|
|
|
*/ |
|
48
|
|
|
public function getTag() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->tag; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Gets the clan's name |
|
55
|
|
|
* |
|
56
|
|
|
* @return string, name |
|
|
|
|
|
|
57
|
|
|
*/ |
|
58
|
|
|
public function getName() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->getClan()->name; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Gets the clan's description |
|
65
|
|
|
* |
|
66
|
|
|
* @return string, description |
|
|
|
|
|
|
67
|
|
|
*/ |
|
68
|
|
|
public function getDescription() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->getClan()->description; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Gets the clan's type |
|
75
|
|
|
* |
|
76
|
|
|
* @return string, type ("open", "inviteOnly" or "closed") |
|
|
|
|
|
|
77
|
|
|
*/ |
|
78
|
|
|
public function getType() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->getClan()->type; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Gets the clan's location ID. You can get more information about a location using the Location.class.php |
|
85
|
|
|
* |
|
86
|
|
|
* @return int, locationId |
|
|
|
|
|
|
87
|
|
|
*/ |
|
88
|
|
|
public function getLocationId() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->getClan()->location->id; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Gets the clan's location. |
|
95
|
|
|
* |
|
96
|
|
|
* @return stdClass |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getLocation() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->getClan()->location; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Get's the URL to the clan badge in the given size. |
|
105
|
|
|
* |
|
106
|
|
|
* @param (optional) $size ("small", "medium", "large") |
|
107
|
|
|
* @return string, URL to the picture |
|
|
|
|
|
|
108
|
|
|
*/ |
|
109
|
|
|
public function getBadgeUrl($size = "") //small, large, medium. |
|
110
|
|
|
{ |
|
111
|
|
|
switch ($size) |
|
112
|
|
|
{ |
|
113
|
|
|
case "small": |
|
114
|
|
|
return $this->getClan()->badgeUrls->small; |
|
115
|
|
|
break; |
|
|
|
|
|
|
116
|
|
|
case "medium": |
|
117
|
|
|
return $this->getClan()->badgeUrls->medium; |
|
118
|
|
|
break; |
|
|
|
|
|
|
119
|
|
|
case "large": |
|
120
|
|
|
return $this->getClan()->badgeUrls->large; |
|
121
|
|
|
break; |
|
|
|
|
|
|
122
|
|
|
default: |
|
123
|
|
|
return $this->getClan()->badgeUrls->large; //return the largest because it can be resized using HTML |
|
124
|
|
|
break; |
|
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Gets the clan's war frequency |
|
131
|
|
|
* |
|
132
|
|
|
* @return string, war-frequency ("always", "lessThanOncePerWeek", "once per week", "moreThanOncePerWeek" or "unknown") |
|
|
|
|
|
|
133
|
|
|
*/ |
|
134
|
|
|
public function getWarFrequency() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->getClan()->warFrequency; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Gets the clan's level |
|
141
|
|
|
* |
|
142
|
|
|
* @return int, level |
|
|
|
|
|
|
143
|
|
|
*/ |
|
144
|
|
|
public function getLevel() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->getClan()->clanLevel; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Gets the clan's war wins |
|
151
|
|
|
* |
|
152
|
|
|
* @return int, wins |
|
|
|
|
|
|
153
|
|
|
*/ |
|
154
|
|
|
public function getWarWins() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->getClan()->warWins; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Gets the clan's war win streak |
|
161
|
|
|
* |
|
162
|
|
|
* @return int, win streak |
|
|
|
|
|
|
163
|
|
|
*/ |
|
164
|
|
|
public function getWarWinStreak() |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->getClan()->warWinStreak; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* Gets the clan's points (trophies) |
|
171
|
|
|
* |
|
172
|
|
|
* @return int, points |
|
|
|
|
|
|
173
|
|
|
*/ |
|
174
|
|
|
public function getPoints() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->getClan()->clanPoints; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Gets the clan's required trophies to join |
|
181
|
|
|
* |
|
182
|
|
|
* @return int, required trophies |
|
|
|
|
|
|
183
|
|
|
*/ |
|
184
|
|
|
public function getRequiredTrophies() |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->getClan()->requiredTrophies; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Gets the amount of members in the clan |
|
191
|
|
|
* |
|
192
|
|
|
* @return int, membercount |
|
|
|
|
|
|
193
|
|
|
*/ |
|
194
|
|
|
public function getMemberCount() |
|
195
|
|
|
{ |
|
196
|
|
|
return $this->getClan()->members; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* Gets a member from the clan by providing an index (usually clan-ranklist position - 1) |
|
201
|
|
|
* Member.class.php will work with the returned class. |
|
202
|
|
|
* |
|
203
|
|
|
* @return stdClass, member |
|
|
|
|
|
|
204
|
|
|
*/ |
|
205
|
|
|
public function getMemberByIndex($index) |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->getClan()->memberList[$index]; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Gets an array of all members in the clan |
|
212
|
|
|
* |
|
213
|
|
|
* @return array (type of stdClass), all members |
|
214
|
|
|
*/ |
|
215
|
|
|
public function getAllMembers() |
|
216
|
|
|
{ |
|
217
|
|
|
return $this->getClan()->memberList; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* Gets the first(!) member with the given name |
|
222
|
|
|
* If there are multiple members using the same name inside the clan, use a different method. |
|
223
|
|
|
* |
|
224
|
|
|
* @return stdClass, member |
|
|
|
|
|
|
225
|
|
|
*/ |
|
226
|
|
|
public function getMemberByName($name) |
|
227
|
|
|
{ |
|
228
|
|
|
foreach ($this->api->getClan()->memberList as $member) |
|
|
|
|
|
|
229
|
|
|
{ |
|
230
|
|
|
if ($member->name == $name) |
|
231
|
|
|
{ |
|
232
|
|
|
return $member; |
|
233
|
|
|
} |
|
234
|
|
|
} |
|
235
|
|
|
return 0; |
|
236
|
|
|
} |
|
237
|
|
|
}; |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.