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.

PlayerRanking::getGeneral()   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
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PlayerRanking
5
 *
6
 * @author Jacky Casas
7
 * @copyright Asylamba
8
 *
9
 * @package Atlas
10
 * @update 04.06.14
11
 */
12
13
namespace Asylamba\Modules\Atlas\Model;
14
15
use Asylamba\Classes\Library\Format;
16
use Asylamba\Modules\Demeter\Resource\ColorResource;
17
18
use Asylamba\Modules\Zeus\Model\Player;
19
20
class PlayerRanking {
21
	# set number of player before you (remove 1) in rank view
22
	const PREV = 4;
23
	# set number of player after you in rank view
24
	const NEXT = 8;
25
	# PREV + NEXT
26
	const STEP = 12;
27
	# set number of player on ajax load page
28
	const PAGE = 10;
29
	
30
	# attributes
31
	public $id; 
32
	public $rRanking;
33
	public $rPlayer; 
34
	
35
	/** @var Player **/
36
	protected $player;
37
38
	public $general;			# pts des bases + flottes + commandants
39
	public $generalPosition;
40
	public $generalVariation;
41
42
	public $experience; 		# experience
43
	public $experiencePosition;
44
	public $experienceVariation;
45
46
	public $butcher;			# destroyedPEV - lostPEV
47
	public $butcherDestroyedPEV;
48
	public $butcherLostPEV;
49
	public $butcherPosition;
50
	public $butcherVariation;
51
52
	public $trader;				# revenu total des routes
53
	public $traderPosition;
54
	public $traderVariation;
55
56
	public $fight; 				# victoires - défaites 
57
	public $victories;
58
	public $defeat;
59
	public $fightPosition;
60
	public $fightVariation;
61
62
	public $armies;				# nb de pev total flotte + hangar
63
	public $armiesPosition;
64
	public $armiesVariation;
65
66
	public $resources; 			# production de ressources par relève (on peut ajouter les recyclages p-e)
67
	public $resourcesPosition;
68
	public $resourcesVariation;
69
70
	# additional attributes
71
	public $color;
72
	public $name;
73
	public $avatar;
74
	public $status;
75
	
76
	/**
77
	 * @param int $id
78
	 * @return PlayerRanking
79
	 */
80
	public function setId($id)
81
	{
82
		$this->id = $id;
83
		
84
		return $this;
85
	}
86
87
	public function getId() { return $this->id; }
0 ignored issues
show
Coding Style introduced by
Opening brace must be the last content on the line
Loading history...
88
89
	/**
90
	 * @param Player $player
91
	 * @return PlayerRanking
92
	 */
93
	public function setPlayer(Player $player)
94
	{
95
		$this->player = $player;
96
		
97
		return $this;
98
	}
99
	
100
	/**
101
	 * @return Player
102
	 */
103
	public function getPlayer()
104
	{
105
		return $this->player;
106
	}
107
	
108
	/**
109
	 * @param int $general
110
	 * @return PlayerRanking
111
	 */
112
	public function setGeneral($general)
113
	{
114
		$this->general = $general;
115
		
116
		return $this;
117
	}
118
	
119
	/**
120
	 * @return int
121
	 */
122
	public function getGeneral()
123
	{
124
		return $this->general;
125
	}
126
	
127
	public function commonRender($playerId, $type) {
128
		$r = '';
129
		$status = ColorResource::getInfo($this->color, 'status');
130
131
		$plus = null;
0 ignored issues
show
Unused Code introduced by
$plus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
132
		$minus = null;
0 ignored issues
show
Unused Code introduced by
$minus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
133
134
		switch ($type) {
135
			case 'general':
136
				$pos = $this->generalPosition;
137
				$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...
138
			case 'xp':
139
				$pos = $this->experiencePosition;
140
				$var = $this->experienceVariation; 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...
141
			case 'butcher':
142
				$pos = $this->butcherPosition;
143
				$plus = $this->butcherDestroyedPEV;
0 ignored issues
show
Unused Code introduced by
$plus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
144
				$minus = $this->butcherLostPEV;
0 ignored issues
show
Unused Code introduced by
$minus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
145
				$var = $this->butcherVariation; 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...
146
			case 'trader':
147
				$pos = $this->traderPosition;
148
				$var = $this->traderVariation; 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...
149
			case 'fight':
150
				$pos = $this->fightPosition;
151
				$plus = $this->victories;
0 ignored issues
show
Unused Code introduced by
$plus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
152
				$minus = $this->defeat;
0 ignored issues
show
Unused Code introduced by
$minus is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
153
				$var = $this->fightVariation; 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...
154
			case 'armies':
155
				$pos = $this->armiesPosition;
156
				$var = $this->armiesVariation; 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...
157
			case 'resources':
158
				$pos = $this->resourcesPosition;
159
				$var = $this->resourcesVariation; 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...
160
			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...
161
		}
162
163
		$r .= '<div class="player color' . $this->color . ' ' . ($playerId == $this->rPlayer ? 'active' : NULL) . '">';
164
			$r .= '<a href="' . APP_ROOT . 'embassy/player-' . $this->rPlayer . '">';
165
				$r .= '<img src="' . MEDIA . 'avatar/small/' . $this->avatar . '.png" alt="' . $this->name . '" class="picto" />';
166
			$r .= '</a>';
167
168
			$r .= '<span class="title">' . $status[$this->status - 1] . '</span>';
169
			$r .= '<strong class="name">' . $this->name . '</strong>';
170
171
			$r .= '<span class="experience">';
172
				switch ($type) {
173
					case 'general': $r .= Format::numberFormat($this->general) . ' point' . Format::addPlural($this->general); 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...
174
					case 'xp': $r .= Format::numberFormat($this->experience) . ' xp'; 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...
175
					case 'butcher': 
176
						$r .= Format::numberFormat($this->butcher) . ' point' . Format::addPlural($this->butcher);
177
						break;
178
					case 'trader': $r .= Format::numberFormat($this->trader) . ' <img src="' . MEDIA . 'resources/credit.png" class="icon-color" alt="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...
179
					case 'fight': 
180
						$r .= Format::numberFormat($this->fight) . ' point' . Format::addPlural($this->fight);
181
						break;
182
				#	case 'armies': $r .= Format::numberFormat($this->armies) . ' <img src="' . MEDIA . 'resources/pev.png" class="icon-color" alt="pev" />'; break;
183
					case 'resources': $r .= Format::numberFormat($this->resources) . ' <img src="' . MEDIA . 'resources/resource.png" class="icon-color" alt="ressources" />'; 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...
184
					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...
185
				}
186
			$r .= '</span>';
187
188
			$r .= '<span class="position">' . $pos . '</span>';
189
190
			if (intval($var) != 0) {
191
				$r .= '<span class="variance ' . ($var > 0 ? ' upper' : ' lower') . '">';
192
					$r .= ($var > 0 ? '+' : '–') . abs($var);
193
				$r .='</span>';
194
			}
195
		$r .= '</div>';
196
197
		return $r;
198
	}
199
}
200