CoC_Clan::getDescription()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
0 ignored issues
show
Bug introduced by
There is no parameter named $isTag. Was it maybe removed?

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 $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
47
	 */
48
   	public function getTag()
49
   	{
50
   		return $this->tag;
51
   	}
52
53
   	/**
54
   	 * Gets the clan's name
55
   	 *
56
   	 * @return string, name
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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")
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
116
			case "medium":
117
				return $this->getClan()->badgeUrls->medium;
118
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
119
			case "large":
120
				return $this->getClan()->badgeUrls->large;
121
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
122
			default:
123
				return $this->getClan()->badgeUrls->large; //return the largest because it can be resized using HTML
124
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
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")
0 ignored issues
show
Documentation introduced by
The doc-type string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type int, could not be parsed: Expected "|" or "end of type", but got "," at position 3. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type stdClass, could not be parsed: Expected "|" or "end of type", but got "," at position 8. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
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
0 ignored issues
show
Documentation introduced by
The doc-type stdClass, could not be parsed: Expected "|" or "end of type", but got "," at position 8. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
225
	 */
226
	public function getMemberByName($name)
227
	{
228
		foreach ($this->api->getClan()->memberList as $member)
0 ignored issues
show
Bug introduced by
The method getClan() does not exist on ClashOfClans. Did you maybe mean getClanByTag()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
229
		{
230
			if ($member->name == $name)
231
			{
232
				return $member;
233
			}
234
		}
235
		return 0;
236
	} 
237
};