Passed
Push — master ( f2e9a4...5d9f44 )
by Tomáš
01:51
created
src/TournamentGenerator/Tournament.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 	private $allowSkip = false;
22 22
 
23
-	function __construct(string $name = ''){
23
+	function __construct(string $name = '') {
24 24
 		$this->name = $name;
25 25
 	}
26 26
 	public function __toString() {
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
 	public function getCategoryWait() {
56 56
 		return $this->expectedCategoryWait;
57 57
 	}
58
-	public function getTournamentTime(){
58
+	public function getTournamentTime() {
59 59
 		$games = count($this->getGames());
60 60
 		return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait;
61 61
 	}
62 62
 
63
-	public function allowSkip(){
63
+	public function allowSkip() {
64 64
 		$this->allowSkip = true;
65 65
 		return $this;
66 66
 	}
67
-	public function disallowSkip(){
67
+	public function disallowSkip() {
68 68
 		$this->allowSkip = false;
69 69
 		return $this;
70 70
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		return $this->allowSkip;
77 77
 	}
78 78
 
79
-	public function addCategory(Category ...$categories){
79
+	public function addCategory(Category ...$categories) {
80 80
 		foreach ($categories as $category) {
81 81
 			if ($category instanceof Category) $this->categories[] = $category;
82 82
 			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	public function addTeam(Team ...$teams) {
119 119
 		foreach ($teams as $team) {
120
-			if ($team instanceof Team)  {
120
+			if ($team instanceof Team) {
121 121
 				$this->teams[] = $team;
122 122
 				continue;
123 123
 			}
Please login to merge, or discard this patch.
Braces   +26 added lines, -11 removed lines patch added patch discarded remove patch
@@ -78,8 +78,11 @@  discard block
 block discarded – undo
78 78
 
79 79
 	public function addCategory(Category ...$categories){
80 80
 		foreach ($categories as $category) {
81
-			if ($category instanceof Category) $this->categories[] = $category;
82
-			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
81
+			if ($category instanceof Category) {
82
+				$this->categories[] = $category;
83
+			} else {
84
+				throw new \Exception('Trying to add category which is not an instance of the Category class.');
85
+			}
83 86
 		}
84 87
 		return $this;
85 88
 	}
@@ -94,8 +97,11 @@  discard block
 block discarded – undo
94 97
 
95 98
 	public function addRound(Round ...$rounds) {
96 99
 		foreach ($rounds as $round) {
97
-			if ($round instanceof Round) $this->rounds[] = $round;
98
-			else throw new \Exception('Trying to add round which is not an instance of the Round class.');
100
+			if ($round instanceof Round) {
101
+				$this->rounds[] = $round;
102
+			} else {
103
+				throw new \Exception('Trying to add round which is not an instance of the Round class.');
104
+			}
99 105
 		}
100 106
 		return $this;
101 107
 	}
@@ -120,8 +126,7 @@  discard block
 block discarded – undo
120 126
 			if ($team instanceof Team)  {
121 127
 				$this->teams[] = $team;
122 128
 				continue;
123
-			}
124
-			elseif (gettype($team) === 'array') {
129
+			} elseif (gettype($team) === 'array') {
125 130
 				$teams = array_merge($teams, array_filter($team, function($a) {
126 131
 					return ($a instanceof Team);
127 132
 				}));
@@ -147,7 +152,9 @@  discard block
 block discarded – undo
147 152
 			}
148 153
 			$this->teams = $teams;
149 154
 		}
150
-		if ($ordered) $this->sortTeams($ordering);
155
+		if ($ordered) {
156
+			$this->sortTeams($ordering);
157
+		}
151 158
 		return $this->teams;
152 159
 	}
153 160
 	public function sortTeams($ordering = \TournamentGenerator\Constants::POINTS) {
@@ -170,7 +177,9 @@  discard block
 block discarded – undo
170 177
 
171 178
 	public function splitTeams(Round ...$wheres) {
172 179
 
173
-		if (count($wheres) === 0) $wheres = $this->getRounds();
180
+		if (count($wheres) === 0) {
181
+			$wheres = $this->getRounds();
182
+		}
174 183
 
175 184
 		foreach ($wheres as $key => $value) {
176 185
 			if (gettype($value) === 'array') {
@@ -185,7 +194,9 @@  discard block
 block discarded – undo
185 194
 
186 195
 		while (count($teams) > 0) {
187 196
 			foreach ($wheres as $where) {
188
-				if (count($teams) > 0) $where->addTeam(array_shift($teams));
197
+				if (count($teams) > 0) {
198
+					$where->addTeam(array_shift($teams));
199
+				}
189 200
 			}
190 201
 		}
191 202
 		foreach ($wheres as $where) {
@@ -197,13 +208,17 @@  discard block
 block discarded – undo
197 208
 	public function genGamesSimulate(bool $returnTime = false) {
198 209
 		$games = Utilis\Simulator::simulateTournament($this);
199 210
 
200
-		if ($returnTime) return $this->getTournamentTime();
211
+		if ($returnTime) {
212
+			return $this->getTournamentTime();
213
+		}
201 214
 		return $games;
202 215
 	}
203 216
 	public function genGamesSimulateReal(bool $returnTime = false) {
204 217
 		$games = Utilis\Simulator::simulateTournamentReal($this);
205 218
 
206
-		if ($returnTime) return $this->getTournamentTime();
219
+		if ($returnTime) {
220
+			return $this->getTournamentTime();
221
+		}
207 222
 		return $games;
208 223
 	}
209 224
 
Please login to merge, or discard this patch.
src/TournamentGenerator/Filter.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
 			if (gettype($filter) === 'array') {
26 26
 				$this->filterMulti($teams, $filter, $key);
27 27
 				continue;
28
-			}
29
-			elseif ($filter instanceof TeamFilter) {
28
+			} elseif ($filter instanceof TeamFilter) {
30 29
 				$teams = array_filter($teams, function($team) use ($filter) {return $filter->validate($team, $this->group->id, 'sum', $this->group); });
31 30
 				continue;
32 31
 			}
@@ -39,12 +38,18 @@  discard block
 block discarded – undo
39 38
 		switch (strtolower($how)) {
40 39
 			case 'and':
41 40
 				foreach ($teams as $tkey => $team) {
42
-					if (!$this->filterAnd($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
41
+					if (!$this->filterAnd($team, $filters)) {
42
+						unset($teams[$tkey]);
43
+					}
44
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
43 45
 				}
44 46
 				return true;
45 47
 			case 'or':
46 48
 				foreach ($teams as $tkey => $team) {
47
-					if (!$this->filterOr($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
49
+					if (!$this->filterOr($team, $filters)) {
50
+						unset($teams[$tkey]);
51
+					}
52
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
48 53
 				}
49 54
 				return true;
50 55
 		}
@@ -56,19 +61,24 @@  discard block
 block discarded – undo
56 61
 			if (gettype($value) === 'array') {
57 62
 				switch (strtolower($key)) {
58 63
 					case 'and':
59
-						if ($this->filterAnd($team, $value)) return false;
64
+						if ($this->filterAnd($team, $value)) {
65
+							return false;
66
+						}
60 67
 						break;
61 68
 					case 'or':
62
-						if ($this->filterOr($team, $value)) return false;
69
+						if ($this->filterOr($team, $value)) {
70
+							return false;
71
+						}
63 72
 						break;
64 73
 					default:
65 74
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
66 75
 						break;
67 76
 				}
68 77
 				continue;
69
-			}
70
-			elseif ($value instanceof TeamFilter) {
71
-				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) return false;
78
+			} elseif ($value instanceof TeamFilter) {
79
+				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) {
80
+					return false;
81
+				}
72 82
 				continue;
73 83
 			}
74 84
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
@@ -80,19 +90,24 @@  discard block
 block discarded – undo
80 90
 			if (gettype($value) === 'array') {
81 91
 				switch (strtolower($key)) {
82 92
 					case 'and':
83
-						if ($this->filterAnd($team, $value)) return true;
93
+						if ($this->filterAnd($team, $value)) {
94
+							return true;
95
+						}
84 96
 						break;
85 97
 					case 'or':
86
-						if ($this->filterOr($team, $value)) return true;
98
+						if ($this->filterOr($team, $value)) {
99
+							return true;
100
+						}
87 101
 						break;
88 102
 					default:
89 103
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
90 104
 						break;
91 105
 				}
92 106
 				continue;
93
-			}
94
-			elseif ($value instanceof TeamFilter) {
95
-				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) return true;
107
+			} elseif ($value instanceof TeamFilter) {
108
+				if (!$value->validate($team, $this->group->id, 'sum', $this->group)) {
109
+					return true;
110
+				}
96 111
 				continue;
97 112
 			}
98 113
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
Please login to merge, or discard this patch.
src/TournamentGenerator/Game.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	/**
97
-	* $results = array (
98
-	* * team->id => team->score
99
-	* )
100
-	*/
97
+	 * $results = array (
98
+	 * * team->id => team->score
99
+	 * )
100
+	 */
101 101
 	public function setResults(array $results = []) {
102 102
 		if (count($this->results) === 0) $this->resetResults();
103 103
 		arsort($results);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,11 +66,11 @@
 block discarded – undo
66 66
 		if (count($error) > 0) throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
67 67
 		return $this;
68 68
 	}
69
-	public function getTeams(){
69
+	public function getTeams() {
70 70
 		return $this->teams;
71 71
 	}
72
-	public function getTeamsIds(){
73
-		return array_map(function($a){ return $a->id; }, $this->teams);
72
+	public function getTeamsIds() {
73
+		return array_map(function($a) { return $a->id; }, $this->teams);
74 74
 	}
75 75
 	public function getTeam(string $id) {
76 76
 		foreach ($this->teams as $team) {
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,11 +33,15 @@  discard block
 block discarded – undo
33 33
 		$this->teams = $teams;
34 34
 		foreach ($this->teams as $team) {
35 35
 			foreach ($this->teams as $team2) {
36
-				if ($team === $team2) continue;
36
+				if ($team === $team2) {
37
+					continue;
38
+				}
37 39
 				$team->addGameWith($team2, $group);
38 40
 			}
39 41
 		}
40
-		if (count($error) > 0) throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
42
+		if (count($error) > 0) {
43
+			throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
44
+		}
41 45
 	}
42 46
 
43 47
 	public function getGroup() {
@@ -56,14 +60,18 @@  discard block
 block discarded – undo
56 60
 			$team->addGame($this);
57 61
 
58 62
 			foreach ($this->teams as $team2) {
59
-				if ($team === $team2) continue;
63
+				if ($team === $team2) {
64
+					continue;
65
+				}
60 66
 				if ($team instanceof Team) {
61 67
 					$team->addGameWith($team2, $this->group);
62 68
 					$team2->addGameWith($team, $this->group);
63 69
 				}
64 70
 			}
65 71
 		}
66
-		if (count($error) > 0) throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
72
+		if (count($error) > 0) {
73
+			throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
74
+		}
67 75
 		return $this;
68 76
 	}
69 77
 	public function getTeams(){
@@ -74,7 +82,9 @@  discard block
 block discarded – undo
74 82
 	}
75 83
 	public function getTeam(string $id) {
76 84
 		foreach ($this->teams as $team) {
77
-			if ($team->id === $id) return $team;
85
+			if ($team->id === $id) {
86
+				return $team;
87
+			}
78 88
 		}
79 89
 		return false;
80 90
 	}
@@ -85,13 +95,17 @@  discard block
 block discarded – undo
85 95
 	* )
86 96
 	*/
87 97
 	public function setResults(array $results = []) {
88
-		if (count($this->results) === 0) $this->resetResults();
98
+		if (count($this->results) === 0) {
99
+			$this->resetResults();
100
+		}
89 101
 		arsort($results);
90 102
 		$inGame = /** @scrutinizer ignore-call */ $this->group->getInGame();
91 103
 		$i = 1;
92 104
 		foreach ($results as $id => $score) {
93 105
 			$team = $this->getTeam($id);
94
-			if ($team === false) throw new \Exception('Couldn\'t find team with id of "'.$id.'"');
106
+			if ($team === false) {
107
+				throw new \Exception('Couldn\'t find team with id of "'.$id.'"');
108
+			}
95 109
 			$this->results[$team->id] = ['score' => $score];
96 110
 			$team->sumScore += $score;
97 111
 			$prev = prev($results);
@@ -118,13 +132,11 @@  discard block
 block discarded – undo
118 132
 			$this->drawIds[] = $team->id;
119 133
 			$team->addDraw($this->group->id);
120 134
 			$this->results[$team->id] += ['points' => $this->group->drawPoints, 'type' => 'draw'];
121
-		}
122
-		elseif ($i === 1) {
135
+		} elseif ($i === 1) {
123 136
 			$this->winId = $team->id;
124 137
 			$team->addWin($this->group->id);
125 138
 			$this->results[$team->id] += ['points' => $this->group->winPoints, 'type' => 'win'];
126
-		}
127
-		else {
139
+		} else {
128 140
 			$this->lossId = $team->id;
129 141
 			$team->addLoss($this->group->id);
130 142
 			$this->results[$team->id] += ['points' => $this->group->lostPoints, 'type' => 'loss'];
@@ -220,7 +232,9 @@  discard block
 block discarded – undo
220 232
 	}
221 233
 
222 234
 	public function isPlayed() {
223
-		if (count($this->results) > 0) return true;
235
+		if (count($this->results) > 0) {
236
+			return true;
237
+		}
224 238
 		return false;
225 239
 	}
226 240
 }
Please login to merge, or discard this patch.
src/TournamentGenerator/Preset/Tournament_2R2G.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
 		$this->splitTeams($round1);
32 32
 
33
-		if (count($this->getTeams()) % 4 == 2) {
33
+		if (count($this->getTeams())%4 == 2) {
34 34
 			$group_top = $round2->group('TOP')->setType(\TournamentGenerator\Constants::ROUND_TWO);
35 35
 
36 36
 			$filter_win_2 = new \TournamentGenerator\TeamFilter('wins', '=', 2, [$group_0_0, $group_top]);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@
 block discarded – undo
12 12
 
13 13
 	public function generate() {
14 14
 
15
-		if (count($this->getTeams()) === 0) throw new \Exception('Couldn\'t generate 2R2G tournament because there are no teams in the tournament.');
15
+		if (count($this->getTeams()) === 0) {
16
+			throw new \Exception('Couldn\'t generate 2R2G tournament because there are no teams in the tournament.');
17
+		}
16 18
 
17 19
 
18 20
 		$round1 = $this->round('Round 1');
Please login to merge, or discard this patch.
src/TournamentGenerator/Preset/Tournament_DoubleElimination.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		$groupIds = [];
32 32
 		$allGroups = [];
33 33
 
34
-		for ($i=1; $i <= $startGroups; $i++) {
34
+		for ($i = 1; $i <= $startGroups; $i++) {
35 35
 			$g = $startRound->group('Start group - '.$i)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO);
36 36
 			$allGroups[] = $g;
37 37
 			$groupIds[] = $g->id;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		// SPLIT TEAMS EVENLY
42 42
 		$this->splitTeams();
43 43
 
44
-		for ($r=2; $r <= $roundsNum-1; $r++) {
44
+		for ($r = 2; $r <= $roundsNum-1; $r++) {
45 45
 			$groups = [];
46 46
 			$losingGroups = [];
47 47
 			$round = $this->round('Round '.$r);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	private function calcByes(int $countTeams, int &$nextPow) {
76 76
 		$byes = 0;
77 77
 		$nextPow = $countTeams;
78
-		if ( !\TournamentGenerator\isPowerOf2($countTeams) ) {
78
+		if (!\TournamentGenerator\isPowerOf2($countTeams)) {
79 79
 			$nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT));
80 80
 			$byes = $nextPow-$countTeams;
81 81
 		}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 	private function generateWinSide(int &$r, int &$byes, int &$countTeams, \TournamentGenerator\Round &$round, array &$allGroups, array &$groups, \TournamentGenerator\Group &$lastWinningGroup = null, array &$previousGroups = []) {
85 85
 		$order = 1;
86
-		for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
86
+		for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
87 87
 			$group = $round->group('Round '.$r.' - win '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order);
88 88
 			$allGroups[] = $group;
89 89
 			$order += 2;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		$losingGroupTeamsCount = count($previousLosingGroups)+count($previousGroups);
99 99
 		$order = 2;
100 100
 		if (\TournamentGenerator\isPowerOf2($losingGroupTeamsCount)) { // IF THE NUMBER OF TEAMS IS A POWER OF 2, GENERATE GROUPS WITHOUT BYES
101
-			for ($g=1; $g <= $losingGroupTeamsCount/2; $g++) {
101
+			for ($g = 1; $g <= $losingGroupTeamsCount/2; $g++) {
102 102
 				$group = $round->group('Round '.$r.' - loss '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order);
103 103
 				$allGroups[] = $group;
104 104
 				$order += 2;
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 			$n = (floor(count($previousLosingGroups)/2)+$losingByes);
122 122
 			$byesGroupsNums = [];
123 123
 			$byesProgressed = 0;
124
-			for ($i=0; $i < $losingByes; $i++) {
124
+			for ($i = 0; $i < $losingByes; $i++) {
125 125
 				$byesGroupsNums[] = $n-($i*2);
126 126
 			}
127 127
 			$lastGroup = 0;
128
-			for ($g=1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
128
+			for ($g = 1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
129 129
 				$group = $round->group('Round '.$r.' - loss '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO)->setOrder($order);
130 130
 				$allGroups[] = $group;
131 131
 				$order += 2;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 				}
138 138
 				else {
139 139
 					$previousLosingGroups[$lastGroup]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
140
-					if (isset($previousLosingGroups[$lastGroup + 1])) $previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
140
+					if (isset($previousLosingGroups[$lastGroup+1])) $previousLosingGroups[$lastGroup+1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
141 141
 					$lastGroup += 2;
142 142
 				}
143 143
 			}
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 		$countTeams = count($this->getTeams());
15 15
 
16
-		if ($countTeams < 3) throw new \Exception('Double elimination is possible for minimum of 3 teams - '.$countTeams.' teams given.');
16
+		if ($countTeams < 3) {
17
+			throw new \Exception('Double elimination is possible for minimum of 3 teams - '.$countTeams.' teams given.');
18
+		}
17 19
 
18 20
 
19 21
 		// CALCULATE BYES
@@ -131,15 +133,19 @@  discard block
 block discarded – undo
131 133
 				if ($r === 2) { // FIRST LOSING ROUND
132 134
 					$previousGroups[2*($g-1)]->progression($group, 1, 1); // PROGRESS FROM STARTING GROUP
133 135
 					$previousGroups[(2*($g-1))+1]->progression($group, 1, 1); // PROGREESS FROM STARTING GROUP
134
-				}
135
-				elseif ($losingGroupTeamsCount >= 2) {
136
+				} elseif ($losingGroupTeamsCount >= 2) {
136 137
 					$previousLosingGroups[$g-1]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
137
-					if (isset(array_reverse($previousGroups)[$g-1])) array_reverse($previousGroups)[$g-1]->progression($group, 1, 1); // PROGREESS FROM WINNING GROUP BEFORE
138
-					else $previousLosingGroups[$g]->progression($group, 0, 1); // PROGRESS OTHER TEAM FROM LOSING GROUP BEEFORE
138
+					if (isset(array_reverse($previousGroups)[$g-1])) {
139
+						array_reverse($previousGroups)[$g-1]->progression($group, 1, 1);
140
+					}
141
+					// PROGREESS FROM WINNING GROUP BEFORE
142
+					else {
143
+						$previousLosingGroups[$g]->progression($group, 0, 1);
144
+					}
145
+					// PROGRESS OTHER TEAM FROM LOSING GROUP BEEFORE
139 146
 				}
140 147
 			}
141
-		}
142
-		else { // IF THE NUMBER OF TEAMS IS NOT A POWER OF 2, GENERATE GROUPS WITH BYES
148
+		} else { // IF THE NUMBER OF TEAMS IS NOT A POWER OF 2, GENERATE GROUPS WITH BYES
143 149
 			// LOOK FOR THE CLOSEST LOWER POWER OF 2
144 150
 			$losingByes = $losingGroupTeamsCount-bindec(str_pad(1, strlen(decbin($losingGroupTeamsCount)), 0, STR_PAD_RIGHT));
145 151
 			$n = (floor(count($previousLosingGroups)/2)+$losingByes);
@@ -163,10 +169,12 @@  discard block
 block discarded – undo
163 169
 				if (in_array($g, $byesGroupsNums) && isset($previousGroups[$byesProgressed])) { // EMPTY GROUP FROM BYE
164 170
 					$previousGroups[$byesProgressed]->progression($group, 1, 1); // PROGRESS FROM WINNING GROUP BEFORE
165 171
 					$byesProgressed++;
166
-				}
167
-				else {
172
+				} else {
168 173
 					$previousLosingGroups[$lastGroup]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
169
-					if (isset($previousLosingGroups[$lastGroup + 1])) $previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
174
+					if (isset($previousLosingGroups[$lastGroup + 1])) {
175
+						$previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1);
176
+					}
177
+					// PROGREESS FROM LOSING GROUP BEFORE
170 178
 					$lastGroup += 2;
171 179
 				}
172 180
 			}
Please login to merge, or discard this patch.
src/TournamentGenerator/Preset/Tournament_SingleElimination.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 		// CALCULATE BYES
18 18
 		$byes = 0;
19
-		if ( !\TournamentGenerator\isPowerOf2($countTeams) ) {
19
+		if (!\TournamentGenerator\isPowerOf2($countTeams)) {
20 20
 			$nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT));
21 21
 			$byes = $nextPow-$countTeams;
22 22
 		}
@@ -27,17 +27,17 @@  discard block
 block discarded – undo
27 27
 
28 28
 		$previousGroups = [];
29 29
 
30
-		for ($i=1; $i <= (($countTeams+$byes)/2); $i++) {
30
+		for ($i = 1; $i <= (($countTeams+$byes)/2); $i++) {
31 31
 			$g = $startRound->group('Round 1 '.$i)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO);
32 32
 			$previousGroups[] = $g;
33 33
 		}
34 34
 
35 35
 		$this->splitTeams();
36 36
 
37
-		for ($r=2; $r <= $roundsNum; $r++) {
37
+		for ($r = 2; $r <= $roundsNum; $r++) {
38 38
 			$groups = [];
39 39
 			$round = $this->round('Round '.$r);
40
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
40
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
41 41
 				$group = $round->group('Round '.$r.' - '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO);
42 42
 				$groups[] = $group;
43 43
 				array_shift($previousGroups)->progression($group, 0, 1); // PROGRESS FROM GROUP BEFORE
Please login to merge, or discard this patch.