GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( dec958...1175d2 )
by Jacky
32s
created

FactionRanking   B

Complexity

Total Complexity 45

Size/Duplication

Total Lines 381
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 381
rs 8.3673
c 0
b 0
f 0
wmc 45
lcom 1
cbo 2

33 Methods

Rating   Name   Duplication   Size   Complexity  
A setId() 0 6 1
A getId() 0 4 1
A setRankingId() 0 6 1
A getRankingId() 0 4 1
A setFactionId() 0 6 1
A getFactionId() 0 4 1
A setPoints() 0 6 1
A getPoints() 0 4 1
A setPointsPosition() 0 6 1
A getPointsPosition() 0 4 1
A setPointsVariation() 0 6 1
A getPointsVariation() 0 4 1
A setNewPoints() 0 6 1
A getNewPoints() 0 4 1
A setGeneral() 0 6 1
A getGeneral() 0 4 1
A setGeneralPosition() 0 6 1
A getGeneralPosition() 0 4 1
A setGeneralVariation() 0 6 1
A getGeneralVariation() 0 4 1
A setWealth() 0 6 1
A getWealth() 0 4 1
A setWealthPosition() 0 6 1
A getWealthPosition() 0 4 1
A setWealthVariation() 0 6 1
A getWealthVariation() 0 4 1
A setTerritorial() 0 6 1
A getTerritorial() 0 4 1
A setTerritorialPosition() 0 6 1
A getTerritorialPosition() 0 4 1
A setTerritorialVariation() 0 6 1
A getTerritorialVariation() 0 4 1
D commonRender() 0 52 13

How to fix   Complexity   

Complex Class

Complex classes like FactionRanking often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use FactionRanking, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * FactionRanking
5
 *
6
 * @author Jacky Casas
7
 * @copyright Asylamba
8
 *
9
 * @package Atlas
10
 * @update 04.06.14
11
 */
12
namespace Asylamba\Modules\Atlas\Model;
13
14
use Asylamba\Classes\Library\Format;
15
use Asylamba\Modules\Demeter\Resource\ColorResource;
16
17
class FactionRanking {
18
	
19
	# attributes
20
	public $id; 
21
	public $rRanking;
22
	public $rFaction; 
23
24
	public $points; 				# accumulated points
25
	public $pointsPosition;
26
	public $pointsVariation;
27
	public $newPoints;
28
29
	public $general; 				# sum of general ranking of the players
30
	public $generalPosition;
31
	public $generalVariation;
32
33
	public $wealth; 				# credits
34
	public $wealthPosition;
35
	public $wealthVariation;
36
37
	public $territorial; 			# sectors owned
38
	public $territorialPosition;
39
	public $territorialVariation;
40
	
41
	/**
42
	 * @param int $id
43
	 * @return FactionRanking
44
	 */
45
	public function setId($id)
46
	{
47
		$this->id = $id;
48
		
49
		return $this;
50
	}
51
52
	/**
53
	 * @return int
54
	 */
55
	public function getId()
56
	{ 
57
		return $this->id;
58
	}
59
60
	/**
61
	 * @param int $rankingId
62
	 * @return FactionRanking
63
	 */
64
	public function setRankingId($rankingId)
65
	{
66
		$this->rRanking = $rankingId;
67
		
68
		return $this;
69
	}
70
	
71
	/**
72
	 * @return int
73
	 */
74
	public function getRankingId()
75
	{
76
		return $this->rRanking;
77
	}
78
	
79
	/**
80
	 * @param int $factionId
81
	 * @return FactionRanking
82
	 */
83
	public function setFactionId($factionId)
84
	{
85
		$this->rFaction = $factionId;
86
		
87
		return $this;
88
	}
89
	
90
	/**
91
	 * @return int
92
	 */
93
	public function getFactionId()
94
	{
95
		return $this->rFaction;
96
	}
97
	
98
	/**
99
	 * @param int $points
100
	 * @return FactionRanking
101
	 */
102
	public function setPoints($points)
103
	{
104
		$this->points = $points;
105
		
106
		return $this;
107
	}
108
	
109
	/**
110
	 * @return int
111
	 */
112
	public function getPoints()
113
	{
114
		return $this->points;
115
	}
116
	
117
	/**
118
	 * @param int $pointsPosition
119
	 * @return FactionRanking
120
	 */
121
	public function setPointsPosition($pointsPosition)
122
	{
123
		$this->pointsPosition = $pointsPosition;
124
		
125
		return $this;
126
	}
127
	
128
	/**
129
	 * @return int
130
	 */
131
	public function getPointsPosition()
132
	{
133
		return $this->pointsPosition;
134
	}
135
	
136
	/**
137
	 * @param int $pointsVariation
138
	 * @return FactionRanking
139
	 */
140
	public function setPointsVariation($pointsVariation)
141
	{
142
		$this->pointsVariation = $pointsVariation;
143
		
144
		return $this;
145
	}
146
	
147
	/**
148
	 * @return int
149
	 */
150
	public function getPointsVariation()
151
	{
152
		return $this->pointsVariation;
153
	}
154
	
155
	/**
156
	 * @param int $newPoints
157
	 * @return FactionRanking
158
	 */
159
	public function setNewPoints($newPoints)
160
	{
161
		$this->newPoints = $newPoints;
162
		
163
		return $this;
164
	}
165
	
166
	/**
167
	 * @return int
168
	 */
169
	public function getNewPoints()
170
	{
171
		return $this->newPoints;
172
	}
173
	
174
	/**
175
	 * @param int $general
176
	 * @return FactionRanking
177
	 */
178
	public function setGeneral($general)
179
	{
180
		$this->general = $general;
181
		
182
		return $this;
183
	}
184
	
185
	/**
186
	 * @return int
187
	 */
188
	public function getGeneral()
189
	{
190
		return $this->general;
191
	}
192
	
193
	/**
194
	 * @param int $generalPosition
195
	 * @return FactionRanking
196
	 */
197
	public function setGeneralPosition($generalPosition)
198
	{
199
		$this->generalPosition = $generalPosition;
200
		
201
		return $this;
202
	}
203
	
204
	/**
205
	 * @return int
206
	 */
207
	public function getGeneralPosition()
208
	{
209
		return $this->generalPosition;
210
	}
211
	
212
	/**
213
	 * @param int $generalVariation
214
	 * @return FactionRanking
215
	 */
216
	public function setGeneralVariation($generalVariation)
217
	{
218
		$this->generalVariation = $generalVariation;
219
		
220
		return $this;
221
	}
222
	
223
	/**
224
	 * @return int
225
	 */
226
	public function getGeneralVariation()
227
	{
228
		return $this->generalVariation;
229
	}
230
	
231
	/**
232
	 * @param int $wealth
233
	 * @return FactionRanking
234
	 */
235
	public function setWealth($wealth)
236
	{
237
		$this->wealth = $wealth;
238
		
239
		return $this;
240
	}
241
	
242
	/**
243
	 * @return int
244
	 */
245
	public function getWealth()
246
	{
247
		return $this->wealth;
248
	}
249
	
250
	/**
251
	 * @param int $wealthPosition
252
	 * @return FactionRanking
253
	 */
254
	public function setWealthPosition($wealthPosition)
255
	{
256
		$this->wealthPosition = $wealthPosition;
257
		
258
		return $this;
259
	}
260
	
261
	/**
262
	 * @return int
263
	 */
264
	public function getWealthPosition()
265
	{
266
		return $this->wealthPosition;
267
	}
268
	
269
	/**
270
	 * @param int $wealthVariation
271
	 * @return FactionRanking
272
	 */
273
	public function setWealthVariation($wealthVariation)
274
	{
275
		$this->wealthVariation = $wealthVariation;
276
		
277
		return $this;
278
	}
279
	
280
	/**
281
	 * @return int
282
	 */
283
	public function getWealthVariation()
284
	{
285
		return $this->wealthVariation;
286
	}
287
	
288
	/**
289
	 * @param int $territorial
290
	 * @return FactionRanking
291
	 */
292
	public function setTerritorial($territorial)
293
	{
294
		$this->territorial = $territorial;
295
		
296
		return $this;
297
	}
298
	
299
	/**
300
	 * @return int
301
	 */
302
	public function getTerritorial()
303
	{
304
		return $this->territorial;
305
	}
306
	
307
	/**
308
	 * @param int $territorialPosition
309
	 * @return FactionRanking
310
	 */
311
	public function setTerritorialPosition($territorialPosition)
312
	{
313
		$this->territorialPosition = $territorialPosition;
314
		
315
		return $this;
316
	}
317
	
318
	/**
319
	 * @return int
320
	 */
321
	public function getTerritorialPosition()
322
	{
323
		return $this->territorialPosition;
324
	}
325
	
326
	/**
327
	 * @param int $territorialVariation
328
	 * @return FactionRanking
329
	 */
330
	public function setTerritorialVariation($territorialVariation)
331
	{
332
		$this->territorialVariation = $territorialVariation;
333
		
334
		return $this;
335
	}
336
	
337
	/**
338
	 * @return int
339
	 */
340
	public function getTerritorialVariation()
341
	{
342
		return $this->territorialVariation;
343
	}
344
	
345
	public function commonRender($playerInfo, $type = 'general') {
346
		$r = '';
347
348
		switch ($type) {
349
			case 'points':
350
				$pos = $this->pointsPosition;
351
				$var = $this->pointsVariation; break;
0 ignored issues
show
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
352
			case 'general':
353
				$pos = $this->generalPosition;
354
				$var = $this->generalVariation; break;
0 ignored issues
show
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
355
			case 'wealth':
356
				$pos = $this->wealthPosition;
357
				$var = $this->wealthVariation; break;
0 ignored issues
show
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
358
			case 'territorial':
359
				$pos = $this->territorialPosition;
360
				$var = $this->territorialVariation; break;
0 ignored issues
show
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
361
			default: $var = ''; $pos = ''; break;
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
362
		}
363
364
		$r .= '<div class="player faction color' . $this->rFaction . ' ' . ($playerInfo->get('color') == $this->rFaction ? 'active' : NULL) . '">';
365
			$r .= '<img src="' . MEDIA . 'faction/flag/flag-' . $this->rFaction . '.png" alt="' . $this->rFaction . '" class="picto" />';
366
367
			$r .= '<span class="title">' . ColorResource::getInfo($this->rFaction, 'government') . '</span>';
368
			$r .= '<strong class="name">' . ColorResource::getInfo($this->rFaction, 'popularName') . '</strong>';
369
			$r .= '<span class="experience">';
370
				switch ($type) {
371
					case 'points': 
372
						$r .= Format::number($this->points, -1) . ' points';
373
						if ($this->newPoints > 0) {
374
							$r .= ' (+' . Format::number($this->newPoints, -1) . ' points)';
375
						}
376
						break;
377
					case 'general': $r .= Format::number($this->general, -1) . ' points'; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
378
					case 'wealth': $r .= Format::number($this->wealth, -1) . ' crédits'; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
379
					case 'territorial': $r .= Format::number($this->territorial, -1) . ' points'; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
380
					default: break;
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
381
				}
382
			$r .= '</span>';
383
384
			$r .= '<span class="position';
385
				$r .= intval($var) == 0
386
					? NULL
387
					: ($var > 0
388
						? ' upper'
389
						: ' lower'
390
					)
391
				;
392
			$r .= '">' . $pos . '</span>';
393
		$r .= '</div>';
394
395
		return $r;
396
	}
397
}
398