Passed
Push — master ( 4dc177...3651e5 )
by Nico
02:23
created

CoC_Clan::getAllMembers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
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
	
35
   	protected function getClan()
36
   	{
37
   		if($this->clan == NULL)
38
		{
39
			$this->clan = $this->api->getClanByTag($this->tag);
40
		}
41
		return $this->clan;
42
   	}
43
44
	/**
45
	 * Gets the clantag
46
	 *
47
	 * @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...
48
	 */
49
   	public function getTag()
50
   	{
51
   		return $this->tag;
52
   	}
53
54
   	/**
55
   	 * Gets the clan's name
56
   	 *
57
   	 * @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...
58
   	 */
59
	public function getName()
60
	{
61
		return $this->getClan()->name;
62
	}
63
64
	/**
65
	 * Gets the clan's description
66
	 *
67
	 * @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...
68
	 */
69
	public function getDescription()
70
	{
71
		return $this->getClan()->description;
72
	}
73
74
	/**
75
	 * Gets the clan's type
76
	 *
77
	 * @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...
78
	 */
79
	public function getType()
80
	{
81
		return $this->getClan()->type;
82
	}
83
84
	/**
85
	 * Gets the clan's location ID. You can get more information about a location using the Location.class.php
86
	 *
87
	 * @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...
88
	 */
89
	public function getLocationId()
90
	{
91
		return $this->getClan()->location->id;
92
	}
93
	
94
	/**
95
	 * Gets the clan's location.
96
	 *
97
	 * @return stdClass
98
	 */
99
	public function getLocation()
100
	{
101
		return $this->getClan()->location;
102
	}
103
104
	/**
105
	 * Get's the URL to the clan badge in the given size.
106
	 * 
107
	 * @param (optional) $size ("small", "medium", "large")
108
	 * @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...
109
	 */
110
	public function getBadgeUrl($size = "") //small, large, medium.
111
	{
112
		switch ($size)
113
		{
114
			case "small":
115
				return $this->getClan()->badgeUrls->small; 
116
				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...
117
			case "medium":
118
				return $this->getClan()->badgeUrls->medium;
119
				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...
120
			case "large":
121
				return $this->getClan()->badgeUrls->large;
122
				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...
123
			default:
124
				return $this->getClan()->badgeUrls->large; //return the largest because it can be resized using HTML
125
				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...
126
		}
127
		
128
	}
129
130
	/**
131
	 * Gets the clan's war frequency
132
	 *
133
	 * @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...
134
	 */
135
	public function getWarFrequency()
136
	{
137
		return $this->getClan()->warFrequency;
138
	}
139
140
	/**
141
	 * Gets the clan's level
142
	 *
143
	 * @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...
144
	 */
145
	public function getLevel()
146
	{
147
		return $this->getClan()->clanLevel;
148
	}
149
150
	/**
151
	 * Gets the clan's war wins
152
	 *
153
	 * @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...
154
	 */
155
	public function getWarWins()
156
	{
157
		return $this->getClan()->warWins;
158
	}
159
160
	/**
161
	 * Gets the clan's points (trophies)
162
	 *
163
	 * @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...
164
	 */
165
	public function getPoints()
166
	{
167
		return $this->getClan()->clanPoints;
168
	}
169
170
	/**
171
	 * Gets the clan's required trophies to join
172
	 *
173
	 * @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...
174
	 */
175
	public function getRequiredTrophies()
176
	{
177
		return $this->getClan()->requiredTrophies;
178
	}
179
180
	/**
181
	 * Gets the amount of members in the clan
182
	 *
183
	 * @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...
184
	 */
185
	public function getMemberCount()
186
	{
187
		return $this->getClan()->members;
188
	}
189
190
	/**
191
	 * Gets a member from the clan by providing an index (usually clan-ranklist position - 1)
192
	 * Member.class.php will work with the returned class.
193
	 *
194
	 * @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...
195
	 */
196
	public function getMemberByIndex($index)
197
	{
198
		return $this->getClan()->memberList[$index];
199
	}
200
201
	/**
202
	 * Gets an array of all members in the clan
203
	 *
204
	 * @return array (type of stdClass), all members
205
	 */
206
	public function getAllMembers()
207
	{
208
		return $this->getClan()->memberList;
209
	}
210
211
	/**
212
	 * Gets the first(!) member with the given name
213
	 * If there are multiple members using the same name inside the clan, use a different method.
214
	 *
215
	 * @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...
216
	 */
217
	public function getMemberByName($name)
218
	{
219
		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...
220
		{
221
			if ($member->name == $name)
222
			{
223
				return $member;
224
			}
225
		}
226
		return 0;
227
	} 
228
};