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 ( 11c0a1...856a6b )
by Jacky
34s
created

Color   C

Complexity

Total Complexity 71

Size/Duplication

Total Lines 779
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 0

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 779
rs 5
wmc 71
lcom 3
cbo 0

71 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getAlive() 0 4 1
A setAlive() 0 6 1
A getIsWinner() 0 4 1
A setIsWinner() 0 6 1
A getCredits() 0 4 1
A setCredits() 0 6 1
A getPlayers() 0 4 1
A setPlayers() 0 6 1
A getActivePlayers() 0 4 1
A setActivePlayers() 0 6 1
A setRankingPoints() 0 6 1
A setOfficialName() 0 6 1
A setId() 0 6 1
A addPlayer() 0 7 1
A getRankingPoints() 0 4 1
A getPoints() 0 4 1
A setPoints() 0 6 1
A getSectors() 0 4 1
A setSectors() 0 6 1
A getElectionStatement() 0 4 1
A setElectionStatement() 0 6 1
A getIsClosed() 0 4 1
A setIsClosed() 0 6 1
A getDescription() 0 4 1
A setDescription() 0 6 1
A getDClaimVictory() 0 4 1
A setDClaimVictory() 0 6 1
A getDLastElection() 0 4 1
A setDLastElection() 0 6 1
A getIsInGame() 0 4 1
A setIsInGame() 0 6 1
A getOfficialName() 0 4 1
A getPopularName() 0 4 1
A setPopularName() 0 6 1
A getGovernment() 0 4 1
A setGovernment() 0 6 1
A getDemonym() 0 4 1
A setDemonym() 0 6 1
A getFactionPoint() 0 4 1
A setFactionPoint() 0 6 1
A getStatus() 0 4 1
A setStatus() 0 6 1
A getRegime() 0 4 1
A setRegime() 0 6 1
A getDevise() 0 4 1
A setDevise() 0 6 1
A getDesc1() 0 4 1
A setDesc1() 0 6 1
A getDesc2() 0 4 1
A setDesc2() 0 6 1
A getDesc3() 0 4 1
A setDesc3() 0 6 1
A getDesc4() 0 4 1
A setDesc4() 0 6 1
A getBonus() 0 4 1
A setBonus() 0 6 1
A getMandateDuration() 0 4 1
A setMandateDuration() 0 6 1
A getSenateDesc() 0 4 1
A setSenateDesc() 0 6 1
A getCampaignDesc() 0 4 1
A setCampaignDesc() 0 6 1
A getBonusText() 0 4 1
A SetBonusText() 0 6 1
A getColorLink() 0 4 1
A setColorLink() 0 6 1
A getChiefId() 0 4 1
A setChiefId() 0 6 1
A increaseCredit() 0 4 1
A decreaseCredit() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Color 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 Color, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * Message Forum
5
 *
6
 * @author Noé Zufferey
7
 * @copyright Expansion - le jeu
8
 *
9
 * @package Demeter
10
 * @update 06.10.13
11
*/
12
13
namespace Asylamba\Modules\Demeter\Model;
14
15
class Color {
16
	# Regime
17
	const DEMOCRATIC 				= 1;
18
	const ROYALISTIC 				= 2;
19
	const THEOCRATIC 				= 3;
20
21
	# Relation avec les autres factions
22
	const NEUTRAL 					= 0;
23
	const PEACE 					= 1;
24
	const ALLY 						= 2;
25
	const ENEMY 					= 3;
26
27
	# constantes de prestiges
28
	const TWO_POINTS_PER_LEVEL 		= 2;
29
	const FOUR_POINTS_PER_LEVEL 	= 4;
30
	## empire
31
	const POINTCONQUER				= 100;
32
	const POINTBUILDBIGSHIP			= 25;
33
34
	## negore
35
	const MIN_PRICE 				= 10000;
36
	const COEF_POINT_SELLING 		= 0.00002; 	# == * 50K
37
38
	## cardan
39
	const BONUSOUTOFSECTOR			= 20;
40
	const POINTDONATE				= 10;
41
	const COEFPOINTDONATE 			= 0.0001;
42
43
	## kovakh
44
	const POINTBUILDLITTLESHIP 		= 1;
45
	const POINTCHANGETYPE 			= 50;
46
	const POINT_BATTLE_WIN			= 10;
47
	const POINT_BATTLE_LOOSE 		= 20;
48
49
	## Synelle
50
	const POINTDEFEND		  		= 20;
51
52
	## Nerve
53
	const COEFFPOINTCONQUER			= 10;
54
	// POINTCHANGETYPE aussi
55
56
	## Aphéra
57
	const POINTSPY					= 10;
58
	const POINTRESEARCH				= 2;
59
60
	# const
61
	const NBRGOVERNMENT 			= 6;
62
63
	const CAMPAIGNTIME 				= 345600;
64
	const ELECTIONTIME				= 172800;
65
	const PUTSCHTIME 				= 25200;
66
67
	const PUTSCHPERCENTAGE			= 15;
68
69
	const ALIVE 					= 1;
70
	const DEAD 						= 0;
71
72
	const MANDATE		 			= 1;
73
	const CAMPAIGN		 			= 2;
74
	const ELECTION 					= 3;
75
76
	const NOT_WIN 					= 0;
77
	const WIN 						= 1;
78
79
	# attributs issus de la db
80
	public $id 						= 0;
81
	public $alive 					= 0;
82
	public $isWinner 				= 0;
83
	public $credits					= 0;
84
	public $players 				= 0;
85
	public $activePlayers 			= 0;
86
	public $rankingPoints 			= 0;
87
	public $points					= 0;
88
	public $sectors					= 0;
89
	public $electionStatement		= 0;
90
	public $isClosed				= 0;
91
	public $description				= 0;
92
	public $dClaimVictory			= '';
93
	public $dLastElection			= '';
94
	public $isInGame 				= 0;
95
96
	# attributs issus des resources
97
	public $officialName 			= '';
98
	public $popularName 			= '';
99
	public $government 				= '';
100
	public $demonym 				= '';
101
	public $factionPoint 			= '';
102
	public $status 					= [''];
103
	public $regime 					= 0;
104
	public $devise 					= '';
105
	public $desc1 					= '';
106
	public $desc2 					= '';
107
	public $desc3 					= '';
108
	public $desc4 					= '';
109
	public $bonus 					= []; # array des id des bonus
110
	public $mandateDuration 		= 0;
111
	public $senateDesc 				= '';
112
	public $campaignDesc 			= '';
113
114
	public $bonusText 				= ['']; # array des descriptions des bonus
115
116
	public $colorLink 				= [];
117
118
	public $chiefId					= 0;
119
120
	/**
121
	 * @return int
122
	 */
123
	public function getId()
124
	{
125
		return $this->id;
126
	}
127
128
	/**
129
	 * @param int $id
130
	 * @return $this
131
	 */
132
	public function setId($id)
133
	{
134
		$this->id = $id;
135
136
		return $this;
137
	}
138
139
	/**
140
	 * @return bool
141
	 */
142
	public function getAlive()
143
	{
144
		return $this->alive;
145
	}
146
147
	/**
148
	 * @param bool $alive
149
	 * @return $this
150
	 */
151
	public function setAlive($alive)
152
	{
153
		$this->alive = $alive;
0 ignored issues
show
Documentation Bug introduced by
The property $alive was declared of type integer, but $alive is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
154
155
		return $this;
156
	}
157
158
	/**
159
	 * @return bool
160
	 */
161
	public function getIsWinner()
162
	{
163
		return $this->isWinner;
164
	}
165
166
	/**
167
	 * @param bool $isWinner
168
	 * @return $this
169
	 */
170
	public function setIsWinner($isWinner)
171
	{
172
		$this->isWinner = $isWinner;
0 ignored issues
show
Documentation Bug introduced by
The property $isWinner was declared of type integer, but $isWinner is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
173
174
		return $this;
175
	}
176
177
	/**
178
	 * @return int
179
	 */
180
	public function getCredits()
181
	{
182
	  return $this->credits;
183
	}
184
185
	/**
186
	 * @param int $credits
187
	 * @return $this
188
	 */
189
	public function setCredits($credits)
190
	{
191
	  $this->credits = $credits;
192
193
	  return $this;
194
	}
195
196
	/**
197
	 * @return array
198
	 */
199
	public function getPlayers()
200
	{
201
	  return $this->players;
202
	}
203
204
	/**
205
	 * @param array $players
206
	 * @return $this
207
	 */
208
	public function setPlayers($players)
209
	{
210
	  $this->players = $players;
0 ignored issues
show
Documentation Bug introduced by
It seems like $players of type array is incompatible with the declared type integer of property $players.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
211
212
	  return $this;
213
	}
214
	/**
215
	 * @param int $idPlayer
216
	 * @return $this
217
	 */
218
	public function addPlayer($idPlayer)
0 ignored issues
show
Unused Code introduced by
The parameter $idPlayer is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
219
	{
220
		//Kern je sais pas s'il le faut, et je sais pas comment l'écrire mais j'hésite avec le setPplayers je sais pas si on set tout d'un coup ou si c'est plutot par ajout
221
		$this->players = players;
222
223
		return $this;
224
	}
225
226
//Kern je connais pas le type non plus, je suppose que c'est un tableau d'int avec les id
227
	/**
228
	 * @return array
229
	 */
230
	public function getActivePlayers()
231
	{
232
	  return $this->activePlayers;
233
	}
234
235
	/**
236
	 * @param array $activePlayers
237
	 * @return $this
238
	 */
239
	public function setActivePlayers($activePlayers)
240
	{
241
	  $this->activePlayers = $activePlayers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $activePlayers of type array is incompatible with the declared type integer of property $activePlayers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
242
243
	  return $this;
244
	}
245
246
	/**
247
	 * @return int
248
	 */
249
	public function getRankingPoints()
250
	{
251
	  return $this->rankingPoints;
252
	}
253
254
	/**
255
	 * @param int $rankingPoints
256
	 * @return $this
257
	 */
258
	public function setRankingPoints($rankingPoints)
259
	{
260
	  $this->rankingPoints = $rankingPoints;
261
262
	  return $this;
263
	}
264
265
	/**
266
	 * @return int
267
	 */
268
	public function getPoints()
269
	{
270
	  return $this->points;
271
	}
272
273
	/**
274
	 * @param int $points
275
	 * @return $this
276
	 */
277
	public function setPoints($points)
278
	{
279
	  $this->points = $points;
280
281
	  return $this;
282
	}
283
284
	/**
285
	 * @return array
286
	 */
287
	public function getSectors()
288
	{
289
	  return $this->id;
290
	}
291
292
	/**
293
	 * @param array $sectors
294
	 * @return $this
295
	 */
296
	public function setSectors($sectors)
297
	{
298
	  $this->sectors = $sectors;
0 ignored issues
show
Documentation Bug introduced by
It seems like $sectors of type array is incompatible with the declared type integer of property $sectors.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
299
300
	  return $this;
301
	}
302
303
	/**
304
	 * @return int
305
	 */
306
	public function getElectionStatement()
307
	{
308
	  return $this->electionStatement;
309
	}
310
311
	/**
312
	 * @param int $electionStatement
313
	 * @return $this
314
	 */
315
	public function setElectionStatement($electionStatement)
316
	{
317
	  $this->electionStatement = $electionStatement;
318
319
	  return $this;
320
	}
321
322
	/**
323
	 * @return bool
324
	 */
325
	public function getIsClosed()
326
	{
327
	  return $this->isClosed;
328
	}
329
330
	/**
331
	 * @param bool $isClosed
332
	 * @return $this
333
	 */
334
	public function setIsClosed($isClosed)
335
	{
336
	  $this->isClosed = $isClosed;
0 ignored issues
show
Documentation Bug introduced by
The property $isClosed was declared of type integer, but $isClosed is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
337
338
	  return $this;
339
	}
340
341
	/**
342
	 * @return string
343
	 */
344
	public function getDescription()
345
	{
346
	  return $this->description;
347
	}
348
	//Kern je me base sur les valeurs par défaut mais ça me semble bizarre : public $description= 0;
349
	/**
350
	 * @param int $description
351
	 * @return $this
352
	 */
353
	public function setDescription($description)
354
	{
355
	  $this->description = $description;
356
357
	  return $this;
358
	}
359
	//Kern Pareil ici : public $dClaimVictory			= '';
360
	/**
361
	 * @return string
362
	 */
363
	public function getDClaimVictory()
364
	{
365
	  return $this->dClaimVictory;
366
	}
367
368
	/**
369
	 * @param string $dClaimVictory
370
	 * @return $this
371
	 */
372
	public function setDClaimVictory($dClaimVictory)
373
	{
374
	  $this->dClaimVictory = $dClaimVictory;
375
376
	  return $this;
377
	}
378
379
	/**
380
	 * @return string
381
	 */
382
	public function getDLastElection()
383
	{
384
	  return $this->dLastElection;
385
	}
386
387
	/**
388
	 * @param string $dLastElection
389
	 * @return $this
390
	 */
391
	public function setDLastElection($dLastElection)
392
	{
393
	  $this->dLastElection = $dLastElection;
394
395
	  return $this;
396
	}
397
398
	/**
399
	 * @return int
400
	 */
401
	public function getIsInGame()
402
	{
403
	  return $this->isInGame;
404
	}
405
406
	/**
407
	 * @param int $isInGame
408
	 * @return $this
409
	 */
410
	public function setIsInGame($isInGame)
411
	{
412
	  $this->isInGame = $isInGame;
413
414
	  return $this;
415
	}
416
417
	/**
418
	 * @return string
419
	 */
420
	public function getOfficialName()
421
	{
422
	  return $this->officialName;
423
	}
424
425
	/**
426
	 * @param string $officialName
427
	 * @return $this
428
	 */
429
	public function setOfficialName($officialName)
430
	{
431
	  $this->officialName = $officialName;
432
433
	  return $this;
434
	}
435
436
	/**
437
	 * @return string
438
	 */
439
	public function getPopularName()
440
	{
441
	  return $this->popularName;
442
	}
443
444
	/**
445
	 * @param string $popularName
446
	 * @return $this
447
	 */
448
	public function setPopularName($popularName)
449
	{
450
	  $this->popularName = $popularName;
451
452
	  return $this;
453
	}
454
455
	/**
456
	 * @return string
457
	 */
458
	public function getGovernment()
459
	{
460
	  return $this->government;
461
	}
462
463
	/**
464
	 * @param string $government
465
	 * @return $this
466
	 */
467
	public function setGovernment($government)
468
	{
469
	  $this->government = $government;
470
471
	  return $this;
472
	}
473
474
	/**
475
	 * @return string
476
	 */
477
	public function getDemonym()
478
	{
479
	  return $this->demonym;
480
	}
481
482
	/**
483
	 * @param string $demonym
484
	 * @return $this
485
	 */
486
	public function setDemonym($demonym)
487
	{
488
	  $this->demonym = $demonym;
489
490
	  return $this;
491
	}
492
493
	/**
494
	 * @return string
495
	 */
496
	public function getFactionPoint()
497
	{
498
	  return $this->factionPoint;
499
	}
500
501
	/**
502
	 * @param string $factionPoint
503
	 * @return $this
504
	 */
505
	public function setFactionPoint($factionPoint)
506
	{
507
	  $this->factionPoint = $factionPoint;
508
509
	  return $this;
510
	}
511
512
	/**
513
	 * @return array
514
	 */
515
	public function getStatus()
516
	{
517
	  return $this->status;
518
	}
519
520
	/**
521
	 * @param array $status
522
	 * @return $this
523
	 */
524
	public function setStatus($status)
525
	{
526
	  $this->status = $status;
527
528
	  return $this;
529
	}
530
531
	/**
532
	 * @return int
533
	 */
534
	public function getRegime()
535
	{
536
	  return $this->regime;
537
	}
538
539
	/**
540
	 * @param int $regime
541
	 * @return $this
542
	 */
543
	public function setRegime($regime)
544
	{
545
	  $this->regime = $regime;
546
547
	  return $this;
548
	}
549
550
	/**
551
	 * @return string
552
	 */
553
	public function getDevise()
554
	{
555
	  return $this->devise;
556
	}
557
558
	/**
559
	 * @param string $devise
560
	 * @return $this
561
	 */
562
	public function setDevise($devise )
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces between argument "$devise" and closing bracket; 1 found
Loading history...
563
	{
564
	  $this->devise = $devise ;
565
566
	  return $this;
567
	}
568
569
	/**
570
	 * @return string
571
	 */
572
	public function getDesc1()
573
	{
574
	  return $this->desc1;
575
	}
576
577
	/**
578
	 * @param string $desc1
579
	 * @return $this
580
	 */
581
	public function setDesc1($desc1)
582
	{
583
	  $this->desc1 = $desc1;
584
585
	  return $this;
586
	}
587
588
	/**
589
	 * @return string
590
	 */
591
	public function getDesc2()
592
	{
593
	  return $this->desc2;
594
	}
595
596
	/**
597
	 * @param string $desc2
598
	 * @return $this
599
	 */
600
	public function setDesc2($desc2)
601
	{
602
	  $this->desc2 = $desc2;
603
604
	  return $this;
605
	}
606
607
	/**
608
	 * @return string
609
	 */
610
	public function getDesc3()
611
	{
612
	  return $this->desc3;
613
	}
614
615
	/**
616
	 * @param string $desc3
617
	 * @return $this
618
	 */
619
	public function setDesc3($desc3)
620
	{
621
	  $this->desc3 = $desc3;
622
623
	  return $this;
624
	}
625
626
	/**
627
	 * @return string
628
	 */
629
	public function getDesc4()
630
	{
631
	  return $this->desc4;
632
	}
633
634
	/**
635
	 * @param string $desc4
636
	 * @return $this
637
	 */
638
	public function setDesc4($desc4)
639
	{
640
	  $this->desc4 = $desc4;
641
642
	  return $this;
643
	}
644
645
	/**
646
	 * @return array
647
	 */
648
	public function getBonus()
649
	{
650
	  return $this->bonus;
651
	}
652
653
	/**
654
	 * @param array $bonus
655
	 * @return $this
656
	 */
657
	public function setBonus($bonus)
658
	{
659
	  $this->bonus = $bonus;
660
661
	  return $this;
662
	}
663
664
	/**
665
	 * @return int
666
	 */
667
	public function getMandateDuration()
668
	{
669
	  return $this->mandateDuration;
670
	}
671
672
	/**
673
	 * @param int $mandateDuration
674
	 * @return $this
675
	 */
676
	public function setMandateDuration($mandateDuration)
677
	{
678
	  $this->mandateDuration = $mandateDuration;
679
680
	  return $this;
681
	}
682
683
	/**
684
	 * @return string
685
	 */
686
	public function getSenateDesc()
687
	{
688
	  return $this->senateDesc;
689
	}
690
691
	/**
692
	 * @param string $senateDesc
693
	 * @return $this
694
	 */
695
	public function setSenateDesc($senateDesc)
696
	{
697
	  $this->senateDesc = $senateDesc;
698
699
	  return $this;
700
	}
701
702
	/**
703
	 * @return int
704
	 */
705
	public function getCampaignDesc()
706
	{
707
	  return $this->campaignDesc;
708
	}
709
710
	/**
711
	 * @param int $campaignDesc
712
	 * @return $this
713
	 */
714
	public function setCampaignDesc($campaignDesc)
715
	{
716
	  $this->campaignDesc = $campaignDesc;
0 ignored issues
show
Documentation Bug introduced by
The property $campaignDesc was declared of type string, but $campaignDesc is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
717
718
	  return $this;
719
	}
720
721
	/**
722
	 * @return array
723
	 */
724
	public function getBonusText()
725
	{
726
	  return $this->bonusText;
727
	}
728
729
	/**
730
	 * @param array $bonusText
731
	 * @return $this
732
	 */
733
	public function SetBonusText($bonusText )
0 ignored issues
show
Coding Style introduced by
Method name "Color::SetBonusText" is not in camel caps format
Loading history...
Coding Style introduced by
Expected 0 spaces between argument "$bonusText" and closing bracket; 1 found
Loading history...
734
	{
735
	  $this->bonusText = $bonusText ;
736
737
	  return $this;
738
	}
739
740
	/**
741
	 * @return array
742
	 */
743
	public function getColorLink()
744
	{
745
	  return $this->colorLink;
746
	}
747
748
	/**
749
	 * @param array $colorLink
750
	 * @return $this
751
	 */
752
	public function setColorLink($colorLink)
753
	{
754
	  $this->colorLink = $colorLink;
755
756
	  return $this;
757
	}
758
759
	/**
760
	 * @return int
761
	 */
762
	public function getChiefId()
763
	{
764
	  return $this->chiefId;
765
	}
766
767
	/**
768
	 * @param int $chiefId
769
	 * @return $this
770
	 */
771
	public function setChiefId($chiefId)
772
	{
773
	  $this->chiefId = $chiefId;
774
775
	  return $this;
776
	}
777
778
	/**
779
	 * @param int $credit
780
	 */
781
	public function increaseCredit($credit) {
782
		$this->credits += $credit;
783
		return $this->credits;
784
	}
785
786
	/**
787
	 * @param int $credit
788
	 */
789
	public function decreaseCredit($credit) {
790
		$this->credits -= $credit;
791
		return $this->credits;
792
	}
793
}
794