Test Setup Failed
Branch master (092d11)
by Tomáš
05:23
created
src/classes/class_team.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@
 block discarded – undo
14 14
 	public $gamesWith = [];
15 15
 
16 16
 	/**
17
-	* ARRAY WITH GROUPS AND IT'S RESULTS
18
-	* array (
19
-	* * groupId => array (
20
-	* * * "group"  => Group, # GROUP OBJECT
21
-	* * * "points" => int 0, # NUMBER OF POINTS AQUIRED
22
-	* * * "score"  => int 0, # SUM OF SCORE AQUIRED
23
-	* * * "wins"   => int 0, # NUMBER OF WINS
24
-	* * * "draws"  => int 0, # NUMBER OF DRAWS
25
-	* * * "losses" => int 0, # NUMBER OF LOSSES
26
-	* * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4)
27
-	* * * "third"  => int 0  # NUMBER OF TIMES BEING THIRD  (ONLY FOR INGAME OPTION OF 4)
28
-	* * )
29
-	*)
30
-	*/
17
+	 * ARRAY WITH GROUPS AND IT'S RESULTS
18
+	 * array (
19
+	 * * groupId => array (
20
+	 * * * "group"  => Group, # GROUP OBJECT
21
+	 * * * "points" => int 0, # NUMBER OF POINTS AQUIRED
22
+	 * * * "score"  => int 0, # SUM OF SCORE AQUIRED
23
+	 * * * "wins"   => int 0, # NUMBER OF WINS
24
+	 * * * "draws"  => int 0, # NUMBER OF DRAWS
25
+	 * * * "losses" => int 0, # NUMBER OF LOSSES
26
+	 * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4)
27
+	 * * * "third"  => int 0  # NUMBER OF TIMES BEING THIRD  (ONLY FOR INGAME OPTION OF 4)
28
+	 * * )
29
+	 *)
30
+	 */
31 31
 	public $groupResults = [];
32 32
 
33 33
 	function __construct(string $name = 'team') {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,61 +41,61 @@
 block discarded – undo
41 41
 		return array_filter($this->groupResults[$groupId], function($k) { return $k !== 'group'; }, ARRAY_FILTER_USE_KEY);
42 42
 	}
43 43
 
44
-	public function addWin(string $groupId = ''){
44
+	public function addWin(string $groupId = '') {
45 45
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
46 46
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints;
47 47
 		$this->groupResults[$groupId]['wins']++;
48 48
 		return $this;
49 49
 	}
50
-	public function removeWin(string $groupId = ''){
50
+	public function removeWin(string $groupId = '') {
51 51
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
52 52
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->winPoints;
53 53
 		$this->groupResults[$groupId]['wins']--;
54 54
 		return $this;
55 55
 	}
56
-	public function addDraw(string $groupId = ''){
56
+	public function addDraw(string $groupId = '') {
57 57
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
58 58
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->drawPoints;
59 59
 		$this->groupResults[$groupId]['draws']++;
60 60
 		return $this;
61 61
 	}
62
-	public function removeDraw(string $groupId = ''){
62
+	public function removeDraw(string $groupId = '') {
63 63
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
64 64
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->drawPointsPoints;
65 65
 		$this->groupResults[$groupId]['draws']--;
66 66
 		return $this;
67 67
 	}
68
-	public function addLoss(string $groupId = ''){
68
+	public function addLoss(string $groupId = '') {
69 69
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
70 70
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->lostPoints;
71 71
 		$this->groupResults[$groupId]['losses']++;
72 72
 		return $this;
73 73
 	}
74
-	public function removeLoss(string $groupId = ''){
74
+	public function removeLoss(string $groupId = '') {
75 75
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
76 76
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->lostPoints;
77 77
 		$this->groupResults[$groupId]['losses']--;
78 78
 		return $this;
79 79
 	}
80
-	public function addSecond(string $groupId = ''){
80
+	public function addSecond(string $groupId = '') {
81 81
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
82 82
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->secondPoints;
83 83
 		$this->groupResults[$groupId]['second']++;
84 84
 		return $this;
85 85
 	}
86
-	public function removeSecond(string $groupId = ''){
86
+	public function removeSecond(string $groupId = '') {
87 87
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
88 88
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->secondPoints;
89 89
 		$this->groupResults[$groupId]['second']--;
90 90
 		return $this;
91 91
 	}
92
-	public function addThird(string $groupId = ''){
92
+	public function addThird(string $groupId = '') {
93 93
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
94 94
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->thirdPoints;
95 95
 		$this->groupResults[$groupId]['third']++;
96 96
 		return $this;
97 97
 	}
98
-	public function removeThird(string $groupId = ''){
98
+	public function removeThird(string $groupId = '') {
99 99
 		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
100 100
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->thirdPoints;
101 101
 		$this->groupResults[$groupId]['third']--;
Please login to merge, or discard this patch.
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,61 +42,81 @@
 block discarded – undo
42 42
 	}
43 43
 
44 44
 	public function addWin(string $groupId = ''){
45
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
45
+		if (!isset($this->groupResults[$groupId])) {
46
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
47
+		}
46 48
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints;
47 49
 		$this->groupResults[$groupId]['wins']++;
48 50
 		return $this;
49 51
 	}
50 52
 	public function removeWin(string $groupId = ''){
51
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
53
+		if (!isset($this->groupResults[$groupId])) {
54
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
55
+		}
52 56
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->winPoints;
53 57
 		$this->groupResults[$groupId]['wins']--;
54 58
 		return $this;
55 59
 	}
56 60
 	public function addDraw(string $groupId = ''){
57
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
61
+		if (!isset($this->groupResults[$groupId])) {
62
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
63
+		}
58 64
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->drawPoints;
59 65
 		$this->groupResults[$groupId]['draws']++;
60 66
 		return $this;
61 67
 	}
62 68
 	public function removeDraw(string $groupId = ''){
63
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
69
+		if (!isset($this->groupResults[$groupId])) {
70
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
71
+		}
64 72
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->drawPointsPoints;
65 73
 		$this->groupResults[$groupId]['draws']--;
66 74
 		return $this;
67 75
 	}
68 76
 	public function addLoss(string $groupId = ''){
69
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
77
+		if (!isset($this->groupResults[$groupId])) {
78
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
79
+		}
70 80
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->lostPoints;
71 81
 		$this->groupResults[$groupId]['losses']++;
72 82
 		return $this;
73 83
 	}
74 84
 	public function removeLoss(string $groupId = ''){
75
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
85
+		if (!isset($this->groupResults[$groupId])) {
86
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
87
+		}
76 88
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->lostPoints;
77 89
 		$this->groupResults[$groupId]['losses']--;
78 90
 		return $this;
79 91
 	}
80 92
 	public function addSecond(string $groupId = ''){
81
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
93
+		if (!isset($this->groupResults[$groupId])) {
94
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
95
+		}
82 96
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->secondPoints;
83 97
 		$this->groupResults[$groupId]['second']++;
84 98
 		return $this;
85 99
 	}
86 100
 	public function removeSecond(string $groupId = ''){
87
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
101
+		if (!isset($this->groupResults[$groupId])) {
102
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
103
+		}
88 104
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->secondPoints;
89 105
 		$this->groupResults[$groupId]['second']--;
90 106
 		return $this;
91 107
 	}
92 108
 	public function addThird(string $groupId = ''){
93
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
109
+		if (!isset($this->groupResults[$groupId])) {
110
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
111
+		}
94 112
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->thirdPoints;
95 113
 		$this->groupResults[$groupId]['third']++;
96 114
 		return $this;
97 115
 	}
98 116
 	public function removeThird(string $groupId = ''){
99
-		if (!isset($this->groupResults[$groupId])) throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
117
+		if (!isset($this->groupResults[$groupId])) {
118
+			throw new Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
119
+		}
100 120
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->thirdPoints;
101 121
 		$this->groupResults[$groupId]['third']--;
102 122
 		return $this;
Please login to merge, or discard this patch.
src/functions.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 function circle_genGames2(array $teams = [], Group $group = null) {
23 23
 	$bracket = []; // ARRAY OF GAMES
24 24
 
25
-	if (count($teams) % 2 != 0) $teams[] = DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
25
+	if (count($teams)%2 != 0) $teams[] = DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
26 26
 
27 27
 	shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS
28 28
 
29
-	for ($i=0; $i < count($teams)-1; $i++) {
29
+	for ($i = 0; $i < count($teams)-1; $i++) {
30 30
 		$bracket = array_merge($bracket, circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND
31 31
 
32 32
 		$teams = circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 	$bracket = [];
43 43
 
44
-	for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
44
+	for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
45 45
 
46 46
 		$home = $teams[$i];
47 47
 		$reverse = array_reverse($teams);
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,10 @@  discard block
 block discarded – undo
22 22
 function circle_genGames2(array $teams = [], Group $group = null) {
23 23
 	$bracket = []; // ARRAY OF GAMES
24 24
 
25
-	if (count($teams) % 2 != 0) $teams[] = DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
25
+	if (count($teams) % 2 != 0) {
26
+		$teams[] = DUMMY_TEAM;
27
+	}
28
+	// IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
26 29
 
27 30
 	shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS
28 31
 
@@ -47,7 +50,10 @@  discard block
 block discarded – undo
47 50
 		$reverse = array_reverse($teams);
48 51
 		$away = $reverse[$i];
49 52
 
50
-		if (($home == DUMMY_TEAM || $away == DUMMY_TEAM)) continue; // SKIP WHEN DUMMY_TEAM IS PRESENT
53
+		if (($home == DUMMY_TEAM || $away == DUMMY_TEAM)) {
54
+			continue;
55
+		}
56
+		// SKIP WHEN DUMMY_TEAM IS PRESENT
51 57
 
52 58
 		$bracket[] = new Game([$home, $away], $group);
53 59
 
Please login to merge, or discard this patch.