Completed
Branch master (0e4a87)
by Tomáš
03:29 queued 01:30
created
src/classes/tournament_presets/class_singleElim.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,7 +27,7 @@  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([
32 32
 				'name' => 'Round 1 - '.$i,
33 33
 				'inGame' => 2,
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 
39 39
 		$this->splitTeams();
40 40
 
41
-		for ($r=2; $r <= $roundsNum; $r++) {
41
+		for ($r = 2; $r <= $roundsNum; $r++) {
42 42
 			$groups = [];
43 43
 			$round = $this->round('Round '.$r);
44
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
44
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
45 45
 				$group = $round->group([
46 46
 					'name' => 'Round '.$r.' - '.$g,
47 47
 					'inGame' => 2,
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_2R2G.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 
51 51
 		$this->splitTeams($round1);
52 52
 
53
-		if (count($this->getTeams()) % 4 == 2) {
53
+		if (count($this->getTeams())%4 == 2) {
54 54
 			$group_top = $round2->group([
55 55
 				'name' => 'TOP',
56 56
 				'type' => TWO_TWO
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_doubleElim.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		// CALCULATE BYES
20 20
 		$byes = 0;
21 21
 		$nextPow = $countTeams;
22
-		if ( !\TournamentGenerator\isPowerOf2($countTeams) ) {
22
+		if (!\TournamentGenerator\isPowerOf2($countTeams)) {
23 23
 			$nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT));
24 24
 			$byes = $nextPow-$countTeams;
25 25
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$groupIds = [];
39 39
 		$allGroups = [];
40 40
 
41
-		for ($i=1; $i <= $startGroups; $i++) {
41
+		for ($i = 1; $i <= $startGroups; $i++) {
42 42
 			$g = $startRound->group([
43 43
 				'name' => 'Start group - '.$i,
44 44
 				'inGame' => 2,
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		// SPLIT TEAMS EVENLY
53 53
 		$this->splitTeams();
54 54
 
55
-		for ($r=2; $r <= $roundsNum-1; $r++) {
55
+		for ($r = 2; $r <= $roundsNum-1; $r++) {
56 56
 			$groups = [];
57 57
 			$losingGroups = [];
58 58
 			$round = $this->round('Round '.$r);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$losingGroupTeamsCount = count($previousLosingGroups)+count($previousGroups);
64 64
 			$order = 2;
65 65
 			if (\TournamentGenerator\isPowerOf2($losingGroupTeamsCount)) { // IF THE NUMBER OF TEAMS IS A POWER OF 2, GENERATE GROUPS WITHOUT BYES
66
-				for ($g=1; $g <= $losingGroupTeamsCount/2; $g++) {
66
+				for ($g = 1; $g <= $losingGroupTeamsCount/2; $g++) {
67 67
 					$group = $round->group([
68 68
 						'name' => 'Round '.$r.' - loss '.$g,
69 69
 						'inGame' => 2,
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 				$n = (floor(count($previousLosingGroups)/2)+$losingByes);
92 92
 				$byesGroupsNums = [];
93 93
 				$byesProgressed = 0;
94
-				for ($i=0; $i < $losingByes; $i++) {
94
+				for ($i = 0; $i < $losingByes; $i++) {
95 95
 					$byesGroupsNums[] = $n-($i*2);
96 96
 				}
97 97
 				$lastGroup = 0;
98
-				for ($g=1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
98
+				for ($g = 1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
99 99
 					$group = $round->group([
100 100
 						'name' => 'Round '.$r.' - loss '.$g,
101 101
 						'inGame' => 2,
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 					}
113 113
 					else {
114 114
 						$previousLosingGroups[$lastGroup]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
115
-						if (isset($previousLosingGroups[$lastGroup + 1])) $previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
115
+						if (isset($previousLosingGroups[$lastGroup+1])) $previousLosingGroups[$lastGroup+1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
116 116
 						$lastGroup += 2;
117 117
 					}
118 118
 				}
119 119
 			}
120 120
 			// WINNING SIDE LIKE SINGLE ELIMINATION
121 121
 			$order = 1;
122
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
122
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
123 123
 				$group = $round->group([
124 124
 					'name' => 'Round '.$r.' - win '.$g,
125 125
 					'inGame' => 2,
Please login to merge, or discard this patch.
src/functions.php 1 patch
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.
src/classes/class_teamFilter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@
 block discarded – undo
45 45
 
46 46
 	private $groups = [];
47 47
 
48
-	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []){
48
+	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []) {
49 49
 		if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) $this->what = strtolower($what);
50 50
 		if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) $this->how = $how;
51 51
 		if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) $this->val = $val;
52 52
 		foreach ($groups as $group) {
53
-			if ($group instanceof Group) $this->groups[] =  $group->id;
53
+			if ($group instanceof Group) $this->groups[] = $group->id;
54 54
 		}
55 55
 	}
56 56
 	public function __toString() {
Please login to merge, or discard this patch.
src/classes/class_tournament.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private $allowSkip = false;
24 24
 
25
-	function __construct(string $name = ''){
25
+	function __construct(string $name = '') {
26 26
 		$this->name = $name;
27 27
 	}
28 28
 	public function __toString() {
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 	public function getCategoryWait() {
58 58
 		return $this->expectedCategoryWait;
59 59
 	}
60
-	public function getTournamentTime(){
60
+	public function getTournamentTime() {
61 61
 		$games = count($this->getGames());
62 62
 		return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait;
63 63
 	}
64 64
 
65
-	public function allowSkip(){
65
+	public function allowSkip() {
66 66
 		$this->allowSkip = true;
67 67
 		return $this;
68 68
 	}
69
-	public function disallowSkip(){
69
+	public function disallowSkip() {
70 70
 		$this->allowSkip = false;
71 71
 		return $this;
72 72
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		return $this->allowSkip;
79 79
 	}
80 80
 
81
-	public function addCategory(Category ...$categories){
81
+	public function addCategory(Category ...$categories) {
82 82
 		foreach ($categories as $category) {
83 83
 			if ($category instanceof Category) $this->categories[] = $category;
84 84
 			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
 	public function addTeam(...$teams) {
121 121
 		foreach ($teams as $team) {
122
-			if ($team instanceof Team)  {
122
+			if ($team instanceof Team) {
123 123
 				$this->teams[] = $team;
124 124
 			}
125 125
 			elseif (gettype($team) === 'array') {
Please login to merge, or discard this patch.
src/classes/class_category.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$this->name = $name;
22 22
 	}
23 23
 
24
-	public function addRound(Round ...$rounds){
24
+	public function addRound(Round ...$rounds) {
25 25
 		foreach ($rounds as $round) {
26 26
 			if ($round instanceof Round) $this->rounds[] = $round;
27 27
 			else throw new \Exception('Trying to add round which is not an instance of Round class.');
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 		$this->rounds[] = $r->setSkip($this->allowSkip);
34 34
 		return $r;
35 35
 	}
36
-	public function getRounds(){
36
+	public function getRounds() {
37 37
 		return $this->rounds;
38 38
 	}
39 39
 
40
-	public function allowSkip(){
40
+	public function allowSkip() {
41 41
 		$this->allowSkip = true;
42 42
 		return $this;
43 43
 	}
44
-	public function disallowSkip(){
44
+	public function disallowSkip() {
45 45
 		$this->allowSkip = false;
46 46
 		return $this;
47 47
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function addTeam(...$teams) {
57 57
 		foreach ($teams as $team) {
58
-			if ($team instanceof Team)  {
58
+			if ($team instanceof Team) {
59 59
 				$this->teams[] = $team;
60 60
 			}
61 61
 			elseif (gettype($team) === 'array') {
Please login to merge, or discard this patch.
src/classes/class_generator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		$this->group = $group;
20 20
 	}
21 21
 
22
-	public function allowSkip(){
22
+	public function allowSkip() {
23 23
 		$this->allowSkip = true;
24 24
 		return $this;
25 25
 	}
26
-	public function disallowSkip(){
26
+	public function disallowSkip() {
27 27
 		$this->allowSkip = false;
28 28
 		return $this;
29 29
 	}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	public function setInGame(int $inGame) {
49
-		if ($inGame < 2 ||  $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
49
+		if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
50 50
 		$this->inGame = $inGame;
51 51
 		return $this;
52 52
 	}
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
 		switch ($this->type) {
68 68
 			case R_R:{
69 69
 					$this->group->addGame($this->r_rGames());
70
-				break;}
70
+				break; }
71 71
 			case TWO_TWO:
72 72
 				$teams = $this->group->getTeams();
73 73
 				$discard = [];
74 74
 				shuffle($teams);
75 75
 				$count = count($teams);
76
-				while (count($teams) % $this->inGame !== 0) { $discard[] = array_shift($teams); }
76
+				while (count($teams)%$this->inGame !== 0) { $discard[] = array_shift($teams); }
77 77
 
78 78
 				while (count($teams) > 0) {
79 79
 					$tInGame = [];
80
-					for ($i=0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
80
+					for ($i = 0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
81 81
 					$this->group->game($tInGame);
82 82
 				}
83 83
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					}
124 124
 					$games = array_merge($games, $gamesTemp);
125 125
 				}
126
-				break;}
126
+				break; }
127 127
 			case 4:{
128 128
 				$teamsB = $teams;
129 129
 				$lockedTeam1 = array_shift($teamsB);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 					$lockedTeam1 = array_shift($teamsB);
141 141
 				}
142 142
 				$games[] = new Game(array_merge([$lockedTeam1], $teamsB), $this->group);
143
-				break;}
143
+				break; }
144 144
 		}
145 145
 		return $games;
146 146
 	}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 			// CYCLE 1
173 173
 			// TEAM WHICH DIDN'T PLAY IN LAST GAME (< 4)
174 174
 			foreach ($games as $key => $game) {
175
-				if ($this->orderCheckTeamsVal($game, $teams, [4,5,6,7])) {
176
-					$this->moveCalculatedGames($game,$teams);
175
+				if ($this->orderCheckTeamsVal($game, $teams, [4, 5, 6, 7])) {
176
+					$this->moveCalculatedGames($game, $teams);
177 177
 					unset($games[$key]);
178 178
 					$found = true;
179 179
 					break;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 			// CYCLE 2
185 185
 			// ! TEAM WHICH PLAYED IN LAST TWO GAMES (NOT 6 or 7)
186 186
 			foreach ($games as $key => $game) {
187
-				if ($this->orderCheckTeamsVal($game, $teams, [6,7])) {
188
-					$this->moveCalculatedGames($game,$teams);
187
+				if ($this->orderCheckTeamsVal($game, $teams, [6, 7])) {
188
+					$this->moveCalculatedGames($game, $teams);
189 189
 					unset($games[$key]);
190 190
 					$found = true;
191 191
 					break;
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 			// NOT TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7)
198 198
 			// TEAMS THAT DIDN'T PLAY IN LAST GAME WILL PLAY THIS GAME (< 4)
199 199
 			foreach ($games as $key => $game) {
200
-				if ($this->orderCheckTeamsVal($game, $teams, [7], [1,2,3])) {
201
-					$this->moveCalculatedGames($game,$teams);
200
+				if ($this->orderCheckTeamsVal($game, $teams, [7], [1, 2, 3])) {
201
+					$this->moveCalculatedGames($game, $teams);
202 202
 					unset($games[$key]);
203 203
 					$found = true;
204 204
 					break;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			// NOT TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7)
211 211
 			foreach ($games as $key => $game) {
212 212
 				if ($this->orderCheckTeamsVal($game, $teams, [7])) {
213
-					$this->moveCalculatedGames($game,$teams);
213
+					$this->moveCalculatedGames($game, $teams);
214 214
 					unset($games[$key]);
215 215
 					$found = true;
216 216
 					break;
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 			// CYCLE 5
222 222
 			// TEAMS THAT DIDN'T PLAY IN LAST GAME WILL PLAY THIS GAME (< 4)
223 223
 			foreach ($games as $key => $game) {
224
-				if ($this->orderCheckTeamsVal($game, $teams, [], [1,2,3])) {
225
-					$this->moveCalculatedGames($game,$teams);
224
+				if ($this->orderCheckTeamsVal($game, $teams, [], [1, 2, 3])) {
225
+					$this->moveCalculatedGames($game, $teams);
226 226
 					unset($games[$key]);
227 227
 					$found = true;
228 228
 					break;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 			// CYCLE 6
234 234
 			// FIRST AVAILABLE GAME
235
-			$this->moveCalculatedGames(array_shift($games),$teams);
235
+			$this->moveCalculatedGames(array_shift($games), $teams);
236 236
 		}
237 237
 
238 238
 		return $this->games;
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	public static function circle_genGames2(array $teams = [], Group $group = null) {
284 284
 		$bracket = []; // ARRAY OF GAMES
285 285
 
286
-		if (count($teams) % 2 != 0) $teams[] = DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
286
+		if (count($teams)%2 != 0) $teams[] = DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
287 287
 
288 288
 		shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS
289 289
 
290
-		for ($i=0; $i < count($teams)-1; $i++) {
290
+		for ($i = 0; $i < count($teams)-1; $i++) {
291 291
 			$bracket = array_merge($bracket, Generator::circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND
292 292
 
293 293
 			$teams = Generator::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 		$bracket = [];
303 303
 
304
-		for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
304
+		for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
305 305
 
306 306
 			$home = $teams[$i];
307 307
 			$reverse = array_reverse($teams);
Please login to merge, or discard this patch.
src/classes/class_game.php 1 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.