Test Setup Failed
Branch master (092d11)
by Tomáš
05:23
created
src/classes/class_category.php 1 patch
Braces   +20 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,8 +21,11 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function addRound(Round ...$rounds){
23 23
 		foreach ($rounds as $round) {
24
-			if ($round instanceof Round) $this->rounds[] = $round;
25
-			else throw new Exception('Trying to add round which is not an instance of Round class.');
24
+			if ($round instanceof Round) {
25
+				$this->rounds[] = $round;
26
+			} else {
27
+				throw new Exception('Trying to add round which is not an instance of Round class.');
28
+			}
26 29
 		}
27 30
 		return $this;
28 31
 	}
@@ -55,13 +58,15 @@  discard block
 block discarded – undo
55 58
 		foreach ($teams as $team) {
56 59
 			if ($team instanceof Team)  {
57 60
 				$this->teams[] = $team;
58
-			}
59
-			elseif (gettype($team) === 'array') {
61
+			} elseif (gettype($team) === 'array') {
60 62
 				foreach ($team as $team2) {
61
-					if ($team2 instanceof Team) $this->teams[] = $team2;
63
+					if ($team2 instanceof Team) {
64
+						$this->teams[] = $team2;
65
+					}
62 66
 				}
67
+			} else {
68
+				throw new Exception('Trying to add team which is not an instance of Team class');
63 69
 			}
64
-			else throw new Exception('Trying to add team which is not an instance of Team class');
65 70
 		}
66 71
 		return $this;
67 72
 	}
@@ -71,7 +76,9 @@  discard block
 block discarded – undo
71 76
 		return $t;
72 77
 	}
73 78
 	public function getTeams() {
74
-		if (count($this->teams) > 0) return $this->teams;
79
+		if (count($this->teams) > 0) {
80
+			return $this->teams;
81
+		}
75 82
 		$teams = [];
76 83
 		foreach ($this->groups as $group) {
77 84
 			$teams = array_merge($teams, $group->getTeams());
@@ -90,7 +97,9 @@  discard block
 block discarded – undo
90 97
 
91 98
 	public function splitTeams(...$rounds) {
92 99
 
93
-		if (count($rounds) === 0) $rounds = $this->getRounds();
100
+		if (count($rounds) === 0) {
101
+			$rounds = $this->getRounds();
102
+		}
94 103
 
95 104
 		$teams = $this->getTeams();
96 105
 		shuffle($teams);
@@ -110,7 +119,9 @@  discard block
 block discarded – undo
110 119
 
111 120
 	public function genGamesSimulate() {
112 121
 		$games = [];
113
-		if (count($this->rounds) <= 0) throw new Exception('There are no rounds to simulate games from.');
122
+		if (count($this->rounds) <= 0) {
123
+			throw new Exception('There are no rounds to simulate games from.');
124
+		}
114 125
 		foreach ($this->rounds as $round) {
115 126
 			$games = array_merge($games, $round->genGames());
116 127
 			$round->simulate()->progressBlank()->resetGames();
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_2R2G.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
 
11 11
 	public function generate() {
12 12
 
13
-		if (count($this->getTeams()) === 0) throw new Exception('Couldn\'t generate 2R2G tournament because there are no teams in the tournament.');
13
+		if (count($this->getTeams()) === 0) {
14
+			throw new Exception('Couldn\'t generate 2R2G tournament because there are no teams in the tournament.');
15
+		}
14 16
 
15 17
 
16 18
 		$round1 = $this->round('Round 1');
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_doubleElim.php 1 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
@@ -77,15 +79,19 @@  discard block
 block discarded – undo
77 79
 					if ($r === 2) { // FIRST LOSING ROUND
78 80
 						$previousGroups[2*($g-1)]->progression($group, 1, 1); // PROGRESS FROM STARTING GROUP
79 81
 						$previousGroups[(2*($g-1))+1]->progression($group, 1, 1); // PROGREESS FROM STARTING GROUP
80
-					}
81
-					elseif ($losingGroupTeamsCount >= 2) {
82
+					} elseif ($losingGroupTeamsCount >= 2) {
82 83
 						$previousLosingGroups[$g-1]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
83
-						if (isset(array_reverse($previousGroups)[$g-1])) array_reverse($previousGroups)[$g-1]->progression($group, 1, 1); // PROGREESS FROM WINNING GROUP BEFORE
84
-						else $previousLosingGroups[$g]->progression($group, 0, 1); // PROGRESS OTHER TEAM FROM LOSING GROUP BEEFORE
84
+						if (isset(array_reverse($previousGroups)[$g-1])) {
85
+							array_reverse($previousGroups)[$g-1]->progression($group, 1, 1);
86
+						}
87
+						// PROGREESS FROM WINNING GROUP BEFORE
88
+						else {
89
+							$previousLosingGroups[$g]->progression($group, 0, 1);
90
+						}
91
+						// PROGRESS OTHER TEAM FROM LOSING GROUP BEEFORE
85 92
 					}
86 93
 				}
87
-			}
88
-			else { // IF THE NUMBER OF TEAMS IS NOT A POWER OF 2, GENERATE GROUPS WITH BYES
94
+			} else { // IF THE NUMBER OF TEAMS IS NOT A POWER OF 2, GENERATE GROUPS WITH BYES
89 95
 				// LOOK FOR THE CLOSEST LOWER POWER OF 2
90 96
 				$losingByes = $losingGroupTeamsCount-bindec(str_pad(1, strlen(decbin($losingGroupTeamsCount)), 0, STR_PAD_RIGHT));
91 97
 				$n = (floor(count($previousLosingGroups)/2)+$losingByes);
@@ -109,10 +115,12 @@  discard block
 block discarded – undo
109 115
 					if (in_array($g, $byesGroupsNums) && isset($previousGroups[$byesProgressed])) { // EMPTY GROUP FROM BYE
110 116
 						$previousGroups[$byesProgressed]->progression($group, 1, 1); // PROGRESS FROM WINNING GROUP BEFORE
111 117
 						$byesProgressed++;
112
-					}
113
-					else {
118
+					} else {
114 119
 						$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
120
+						if (isset($previousLosingGroups[$lastGroup + 1])) {
121
+							$previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1);
122
+						}
123
+						// PROGREESS FROM LOSING GROUP BEFORE
116 124
 						$lastGroup += 2;
117 125
 					}
118 126
 				}
Please login to merge, or discard this patch.
src/classes/class_teamFilter.php 1 patch
Braces   +38 added lines, -19 removed lines patch added patch discarded remove patch
@@ -44,11 +44,19 @@  discard block
 block discarded – undo
44 44
 	private $groups = [];
45 45
 
46 46
 	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []){
47
-		if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) $this->what = strtolower($what);
48
-		if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) $this->how = $how;
49
-		if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) $this->val = $val;
47
+		if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) {
48
+			$this->what = strtolower($what);
49
+		}
50
+		if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) {
51
+			$this->how = $how;
52
+		}
53
+		if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) {
54
+			$this->val = $val;
55
+		}
50 56
 		foreach ($groups as $group) {
51
-			if ($group instanceof Group) $this->groups[] =  $group->id;
57
+			if ($group instanceof Group) {
58
+				$this->groups[] =  $group->id;
59
+			}
52 60
 		}
53 61
 	}
54 62
 	function __toString() {
@@ -56,35 +64,48 @@  discard block
 block discarded – undo
56 64
 	}
57 65
 
58 66
 	public function validate(Team $team, $groupsId, string $operation = 'sum', Group $from = null) {
59
-		if (count($this->groups) > 0) $groupsId = array_unique(array_merge($this->groups, (gettype($groupsId) === 'array' ? $groupsId : [$groupsId])), SORT_REGULAR);
67
+		if (count($this->groups) > 0) {
68
+			$groupsId = array_unique(array_merge($this->groups, (gettype($groupsId) === 'array' ? $groupsId : [$groupsId])), SORT_REGULAR);
69
+		}
60 70
 		if ($this->what == 'team') {
61 71
 			switch ($this->how) {
62 72
 				case '=':
63
-					if ($this->val === $team) return true;
73
+					if ($this->val === $team) {
74
+						return true;
75
+					}
64 76
 					break;
65 77
 				case '!=':
66
-					if ($this->val !== $team) return true;
78
+					if ($this->val !== $team) {
79
+						return true;
80
+					}
67 81
 					break;
68 82
 			}
69 83
 			return false;
70
-		}
71
-		elseif ($this->what == 'notprogressed') {
84
+		} elseif ($this->what == 'notprogressed') {
72 85
 			return !$from->progressed($team);
73
-		}
74
-		elseif ($this->what == 'progressed') {
86
+		} elseif ($this->what == 'progressed') {
75 87
 			return $from->progressed($team);
76 88
 		}
77
-		if (gettype($groupsId) === 'array' && !in_array(strtolower($operation), ['sum', 'avg', 'max', 'min'])) throw new Exception('Unknown operation of '.$sum.'. Only "sum", "avg", "min", "max" possible.');
89
+		if (gettype($groupsId) === 'array' && !in_array(strtolower($operation), ['sum', 'avg', 'max', 'min'])) {
90
+			throw new Exception('Unknown operation of '.$sum.'. Only "sum", "avg", "min", "max" possible.');
91
+		}
78 92
 		$comp = 0;
79 93
 		if (gettype($groupsId) === 'array' && count($groupsId) > 0) {
80 94
 			$sum = 0;
81 95
 			$max = null;
82 96
 			$min = null;
83 97
 			foreach ($groupsId as $id) {
84
-				if (!isset($team->groupResults[$id])) continue; // IF TEAM DIDN'T PLAY IN THAT GROUP -> SKIP
98
+				if (!isset($team->groupResults[$id])) {
99
+					continue;
100
+				}
101
+				// IF TEAM DIDN'T PLAY IN THAT GROUP -> SKIP
85 102
 				$sum += $team->groupResults[$id][$this->what];
86
-				if ($team->groupResults[$id][$this->what] > $max || $max === null) $max = $team->groupResults[$id][$this->what];
87
-				if ($team->groupResults[$id][$this->what] < $min || $min === null) $min = $team->groupResults[$id][$this->what];
103
+				if ($team->groupResults[$id][$this->what] > $max || $max === null) {
104
+					$max = $team->groupResults[$id][$this->what];
105
+				}
106
+				if ($team->groupResults[$id][$this->what] < $min || $min === null) {
107
+					$min = $team->groupResults[$id][$this->what];
108
+				}
88 109
 			}
89 110
 			switch (strtolower($operation)) {
90 111
 				case 'sum':
@@ -100,11 +121,9 @@  discard block
 block discarded – undo
100 121
 					$comp = $min;
101 122
 					break;
102 123
 			}
103
-		}
104
-		elseif (gettype($groupsId) === 'string' && isset($team->groupResults[$groupsId])) {
124
+		} elseif (gettype($groupsId) === 'string' && isset($team->groupResults[$groupsId])) {
105 125
 			$comp = $team->groupResults[$groupsId][$this->what];
106
-		}
107
-		else {
126
+		} else {
108 127
 			throw new Exception("Couldn't find group of id ".print_r($groupsId, true));
109 128
 		}
110 129
 
Please login to merge, or discard this patch.
src/classes/class_game.php 1 patch
Braces   +40 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,9 +25,10 @@  discard block
 block discarded – undo
25 25
 			if (!$team instanceof Team) {
26 26
 				$error[] = $team;
27 27
 				unset($teams[$key]);
28
-			}
29
-			else {
30
-				if (!isset($team->games[$group->id])) $team->games[$group->id] = [];
28
+			} else {
29
+				if (!isset($team->games[$group->id])) {
30
+					$team->games[$group->id] = [];
31
+				}
31 32
 				$team->games[$group->id][] = $this;
32 33
 				$tids[] = $team->id;
33 34
 			}
@@ -36,12 +37,16 @@  discard block
 block discarded – undo
36 37
 		foreach ($this->teams as $team) {
37 38
 			foreach ($tids as $id) {
38 39
 				if ($team->id !== $id) {
39
-					if (!isset($team->gamesWith[$group->id][$id])) $team->gamesWith[$group->id][$id] = 0;
40
+					if (!isset($team->gamesWith[$group->id][$id])) {
41
+						$team->gamesWith[$group->id][$id] = 0;
42
+					}
40 43
 					$team->gamesWith[$group->id][$id]++;
41 44
 				}
42 45
 			}
43 46
 		}
44
-		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));
47
+		if (count($error) > 0) {
48
+			throw new Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
49
+		}
45 50
 	}
46 51
 
47 52
 	public function addTeam(...$teams) {
@@ -49,9 +54,13 @@  discard block
 block discarded – undo
49 54
 		foreach ($this->teams as $team) {
50 55
 			foreach ($teams as $team2) {
51 56
 				if ($team2 instanceof Team) {
52
-					if (!isset($team->gamesWith[$this->group->id][$team2->id])) $team->gamesWith[$this->group->id][$team2->id] = 0;
57
+					if (!isset($team->gamesWith[$this->group->id][$team2->id])) {
58
+						$team->gamesWith[$this->group->id][$team2->id] = 0;
59
+					}
53 60
 					$team->gamesWith[$this->group->id][$team2->id]++;
54
-					if (!isset($team2->gamesWith[$this->group->id][$team->id])) $team2->gamesWith[$this->group->id][$team->id] = 0;
61
+					if (!isset($team2->gamesWith[$this->group->id][$team->id])) {
62
+						$team2->gamesWith[$this->group->id][$team->id] = 0;
63
+					}
55 64
 					$team2->gamesWith[$this->group->id][$team->id]++;
56 65
 				}
57 66
 			}
@@ -59,21 +68,26 @@  discard block
 block discarded – undo
59 68
 		foreach ($teams as $key => $team) {
60 69
 			if ($team instanceof Team) {
61 70
 				$this->teams[] = $team;
62
-				if (!isset($team->games[$this->group->id])) $team->games[$this->group->id] = [];
71
+				if (!isset($team->games[$this->group->id])) {
72
+					$team->games[$this->group->id] = [];
73
+				}
63 74
 				$team->games[$this->group->id][] = $this;
64 75
 				foreach ($teams as $key2 => $team2) {
65 76
 					if ($team2 instanceof Team) {
66
-						if (!isset($team->gamesWith[$this->group->id][$team2->id])) $team->gamesWith[$this->group->id][$team2->id] = 0;
77
+						if (!isset($team->gamesWith[$this->group->id][$team2->id])) {
78
+							$team->gamesWith[$this->group->id][$team2->id] = 0;
79
+						}
67 80
 						$team->gamesWith[$this->group->id][$team2->id]++;
68 81
 					}
69 82
 				}
70
-			}
71
-			else {
83
+			} else {
72 84
 				$error[] = $team;
73 85
 				unset($teams[$key]);
74 86
 			}
75 87
 		}
76
-		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));
88
+		if (count($error) > 0) {
89
+			throw new Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
90
+		}
77 91
 		return $this;
78 92
 	}
79 93
 	public function getTeams(){
@@ -88,7 +102,9 @@  discard block
 block discarded – undo
88 102
 	}
89 103
 	public function getTeam(string $id) {
90 104
 		foreach ($this->teams as $team) {
91
-			if ($team->id === $id) return $team;
105
+			if ($team->id === $id) {
106
+				return $team;
107
+			}
92 108
 		}
93 109
 		return false;
94 110
 	}
@@ -99,12 +115,16 @@  discard block
 block discarded – undo
99 115
 	* )
100 116
 	*/
101 117
 	public function setResults(array $results = []) {
102
-		if (count($this->results) === 0) $this->resetResults();
118
+		if (count($this->results) === 0) {
119
+			$this->resetResults();
120
+		}
103 121
 		arsort($results);
104 122
 		$i = 1;
105 123
 		foreach ($results as $id => $score) {
106 124
 			$team = $this->getTeam($id);
107
-			if ($team === false) throw new Exception('Couldn\'t find team with id of "'.$id.'"');
125
+			if ($team === false) {
126
+				throw new Exception('Couldn\'t find team with id of "'.$id.'"');
127
+			}
108 128
 			$this->results[$team->id] = ['score' => $score];
109 129
 			$prev = prev($results);
110 130
 			next($results);
@@ -115,13 +135,11 @@  discard block
 block discarded – undo
115 135
 						$this->drawIds[] = $team->id;
116 136
 						$team->addDraw($this->group->id);
117 137
 						$this->results[$team->id] += ['points' => $this->group->drawPoints, 'type' => 'draw'];
118
-					}
119
-					elseif ($i === 1) {
138
+					} elseif ($i === 1) {
120 139
 						$this->winId = $team->id;
121 140
 						$team->addWin($this->group->id);
122 141
 						$this->results[$team->id] += ['points' => $this->group->winPoints, 'type' => 'win'];
123
-					}
124
-					else {
142
+					} else {
125 143
 						$this->lossId = $team->id;
126 144
 						$team->addLoss($this->group->id);
127 145
 						$this->results[$team->id] += ['points' => $this->group->lostPoints, 'type' => 'loss'];
@@ -218,7 +236,9 @@  discard block
 block discarded – undo
218 236
 	}
219 237
 
220 238
 	public function isPlayed() {
221
-		if (count($this->results) > 0) return true;
239
+		if (count($this->results) > 0) {
240
+			return true;
241
+		}
222 242
 		return false;
223 243
 	}
224 244
 }
Please login to merge, or discard this patch.
src/classes/class_group.php 1 patch
Braces   +143 added lines, -70 removed lines patch added patch discarded remove patch
@@ -31,23 +31,36 @@  discard block
 block discarded – undo
31 31
 		foreach ($settings as $key => $value) {
32 32
 			switch ($key) {
33 33
 				case 'name':
34
-					if (gettype($value) === 'string') $this->name = $value;
35
-					else throw new Exception('Expected string as group name '.gettype($value).' given');
34
+					if (gettype($value) === 'string') {
35
+						$this->name = $value;
36
+					} else {
37
+						throw new Exception('Expected string as group name '.gettype($value).' given');
38
+					}
36 39
 					break;
37 40
 				case 'type':
38
-					if (in_array($value, groupTypes)) $this->type = $value;
39
-					else throw new Exception('Unknown group type: '.$value);
41
+					if (in_array($value, groupTypes)) {
42
+						$this->type = $value;
43
+					} else {
44
+						throw new Exception('Unknown group type: '.$value);
45
+					}
40 46
 					break;
41 47
 				case 'ordering':
42
-					if (in_array($value, orderingTypes)) $this->ordering = $value;
43
-					else throw new Exception('Unknown group ordering: '.$value);
48
+					if (in_array($value, orderingTypes)) {
49
+						$this->ordering = $value;
50
+					} else {
51
+						throw new Exception('Unknown group ordering: '.$value);
52
+					}
44 53
 					break;
45 54
 				case 'inGame':
46 55
 					if (gettype($value) === 'integer') {
47
-						if ($value === 2 || $value === 3 || $value === 4) $this->inGame = $value;
48
-						else throw new Exception('Expected 2,3 or 4 as inGame '.$value.' given');
56
+						if ($value === 2 || $value === 3 || $value === 4) {
57
+							$this->inGame = $value;
58
+						} else {
59
+							throw new Exception('Expected 2,3 or 4 as inGame '.$value.' given');
60
+						}
61
+					} else {
62
+						throw new Exception('Expected integer as inGame '.gettype($value).' given');
49 63
 					}
50
-					else throw new Exception('Expected integer as inGame '.gettype($value).' given');
51 64
 					break;
52 65
 				case 'maxSize':
53 66
 					if (gettype($value) === 'integer') {
@@ -96,10 +109,11 @@  discard block
 block discarded – undo
96 109
 					'second' => 0,
97 110
 					'third'  => 0
98 111
 				];
99
-			}
100
-			elseif (gettype($team) === 'array') {
112
+			} elseif (gettype($team) === 'array') {
101 113
 				foreach ($team as $team2) {
102
-					if ($team2 instanceof Team) $this->teams[] = $team2;
114
+					if ($team2 instanceof Team) {
115
+						$this->teams[] = $team2;
116
+					}
103 117
 					$team2->groupResults[$this->id] = [
104 118
 						'group' => $this,
105 119
 						'points' => 0,
@@ -111,16 +125,20 @@  discard block
 block discarded – undo
111 125
 						'third'  => 0
112 126
 					];
113 127
 				}
128
+			} else {
129
+				throw new Exception('Trying to add team which is not an instance of Team class');
114 130
 			}
115
-			else throw new Exception('Trying to add team which is not an instance of Team class');
116 131
 		}
117 132
 		return $this;
118 133
 	}
119 134
 	public function getTeams($filters = []) {
120 135
 		$teams = $this->teams;
121 136
 
122
-		if (gettype($filters) !== 'array' && $filters instanceof TeamFilter) $filters = [$filters];
123
-		elseif (gettype($filters) !== 'array') $filters = [];
137
+		if (gettype($filters) !== 'array' && $filters instanceof TeamFilter) {
138
+			$filters = [$filters];
139
+		} elseif (gettype($filters) !== 'array') {
140
+			$filters = [];
141
+		}
124 142
 
125 143
 		// APPLY FILTERS
126 144
 		foreach ($filters as $key => $filter) {
@@ -140,15 +158,13 @@  discard block
 block discarded – undo
140 158
 						throw new Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
141 159
 						break;
142 160
 				}
143
-			}
144
-			elseif ($filter instanceof TeamFilter) {
161
+			} elseif ($filter instanceof TeamFilter) {
145 162
 				foreach ($teams as $tkey => $team) {
146 163
 					if (!$filter->validate($team, $this->id, 'sum', $this)) {
147 164
 						unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
148 165
 					}
149 166
 				}
150
-			}
151
-			else {
167
+			} else {
152 168
 				throw new Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
153 169
 				return [];
154 170
 			}
@@ -160,20 +176,24 @@  discard block
 block discarded – undo
160 176
 			if (gettype($value) === 'array') {
161 177
 				switch (strtolower($key)) {
162 178
 					case 'and':
163
-						if ($this->filterAnd($team, $value)) return false;
179
+						if ($this->filterAnd($team, $value)) {
180
+							return false;
181
+						}
164 182
 						break;
165 183
 					case 'or':
166
-						if ($this->filterOr($team, $value)) return false;
184
+						if ($this->filterOr($team, $value)) {
185
+							return false;
186
+						}
167 187
 						break;
168 188
 					default:
169 189
 						throw new Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
170 190
 						break;
171 191
 				}
172
-			}
173
-			elseif ($value instanceof TeamFilter) {
174
-				if (!$filter->validate($team, $this->id, 'sum', $this)) return false;
175
-			}
176
-			else {
192
+			} elseif ($value instanceof TeamFilter) {
193
+				if (!$filter->validate($team, $this->id, 'sum', $this)) {
194
+					return false;
195
+				}
196
+			} else {
177 197
 				throw new Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
178 198
 			}
179 199
 		}
@@ -184,20 +204,24 @@  discard block
 block discarded – undo
184 204
 			if (gettype($value) === 'array') {
185 205
 				switch (strtolower($key)) {
186 206
 					case 'and':
187
-						if ($this->filterAnd($team, $value)) return true;
207
+						if ($this->filterAnd($team, $value)) {
208
+							return true;
209
+						}
188 210
 						break;
189 211
 					case 'or':
190
-						if ($this->filterOr($team, $value)) return true;
212
+						if ($this->filterOr($team, $value)) {
213
+							return true;
214
+						}
191 215
 						break;
192 216
 					default:
193 217
 						throw new Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
194 218
 						break;
195 219
 				}
196
-			}
197
-			elseif ($value instanceof TeamFilter) {
198
-				if (!$filter->validate($team, $this->id, 'sum', $this)) return true;
199
-			}
200
-			else {
220
+			} elseif ($value instanceof TeamFilter) {
221
+				if (!$filter->validate($team, $this->id, 'sum', $this)) {
222
+					return true;
223
+				}
224
+			} else {
201 225
 				throw new Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
202 226
 			}
203 227
 		}
@@ -219,16 +243,22 @@  discard block
 block discarded – undo
219 243
 		return $t;
220 244
 	}
221 245
 	public function setType(string $type = R_R) {
222
-		if (in_array($type, groupTypes)) $this->type = $type;
223
-		else throw new Exception('Unknown group type: '.$type);
246
+		if (in_array($type, groupTypes)) {
247
+			$this->type = $type;
248
+		} else {
249
+			throw new Exception('Unknown group type: '.$type);
250
+		}
224 251
 		return $this;
225 252
 	}
226 253
 	public function getType() {
227 254
 		return $this->type;
228 255
 	}
229 256
 	public function setOrdering(string $ordering = POINTS) {
230
-		if (in_array($ordering, orderingTypes)) $this->ordering = $ordering;
231
-		else throw new Exception('Unknown group ordering: '.$ordering);
257
+		if (in_array($ordering, orderingTypes)) {
258
+			$this->ordering = $ordering;
259
+		} else {
260
+			throw new Exception('Unknown group ordering: '.$ordering);
261
+		}
232 262
 		return $this;
233 263
 	}
234 264
 	public function getOrdering() {
@@ -238,14 +268,20 @@  discard block
 block discarded – undo
238 268
 		switch ($this->ordering) {
239 269
 			case POINTS:{
240 270
 				usort($this->teams, function($a, $b) {
241
-					if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"] && $a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) return 0;
242
-					if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"]) return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1);
271
+					if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"] && $a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) {
272
+						return 0;
273
+					}
274
+					if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"]) {
275
+						return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1);
276
+					}
243 277
 					return ($a->groupResults[$this->id]["points"] > $b->groupResults[$this->id]["points"] ? -1 : 1);
244 278
 				});
245 279
 				break;}
246 280
 			case SCORE:{
247 281
 				usort($this->teams, function($a, $b) {
248
-					if ($a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) return 0;
282
+					if ($a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) {
283
+						return 0;
284
+					}
249 285
 					return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1);
250 286
 				});
251 287
 				break;}
@@ -254,17 +290,24 @@  discard block
 block discarded – undo
254 290
 	}
255 291
 	public function setInGame(int $inGame) {
256 292
 		if (gettype($inGame) === 'integer') {
257
-			if ($inGame === 2 || $inGame === 3 || $inGame === 4) $this->inGame = $inGame;
258
-			else throw new Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
293
+			if ($inGame === 2 || $inGame === 3 || $inGame === 4) {
294
+				$this->inGame = $inGame;
295
+			} else {
296
+				throw new Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
297
+			}
298
+		} else {
299
+			throw new Exception('Expected integer as inGame '.gettype($inGame).' given');
259 300
 		}
260
-		else throw new Exception('Expected integer as inGame '.gettype($inGame).' given');
261 301
 	}
262 302
 	public function getInGame() {
263 303
 		return $this->inGame;
264 304
 	}
265 305
 	public function addProgression(Progression $progression) {
266
-		if ($progression instanceof Progression) $this->progressions[] = $progression;
267
-		else throw new Exception('Trying to add progression which is not an instance of Progression class');
306
+		if ($progression instanceof Progression) {
307
+			$this->progressions[] = $progression;
308
+		} else {
309
+			throw new Exception('Trying to add progression which is not an instance of Progression class');
310
+		}
268 311
 		return $this;
269 312
 	}
270 313
 	public function progression(Group $to, int $start = 0, int $len = null) {
@@ -286,16 +329,13 @@  discard block
 block discarded – undo
286 329
 		foreach ($teams as $team) {
287 330
 			if ($team instanceOf Team) {
288 331
 				$this->progressed[] = $team->id;
289
-			}
290
-			elseif (gettype($team) === 'string' || gettype($team) === 'integer') {
332
+			} elseif (gettype($team) === 'string' || gettype($team) === 'integer') {
291 333
 				$this->progressed[] = $team;
292
-			}
293
-			elseif (gettype($team) === 'array') {
334
+			} elseif (gettype($team) === 'array') {
294 335
 				foreach ($team as $teamInner) {
295 336
 					if ($teamInner instanceOf Team) {
296 337
 						$this->progressed[] = $teamInner->id;
297
-					}
298
-					elseif (gettype($teamInner) === 'string' || gettype($teamInner) === 'integer') {
338
+					} elseif (gettype($teamInner) === 'string' || gettype($teamInner) === 'integer') {
299 339
 						$this->progressed[] = $teamInner;
300 340
 					}
301 341
 				}
@@ -349,12 +389,15 @@  discard block
 block discarded – undo
349 389
 					while ($g > 0) {
350 390
 						foreach ($games as $key => $group) {
351 391
 							$this->games[] = array_shift($games[$key]);
352
-							if (count($games[$key]) === 0) unset($games[$key]);
392
+							if (count($games[$key]) === 0) {
393
+								unset($games[$key]);
394
+							}
353 395
 							$g--;
354 396
 						}
355 397
 					}
398
+				} else {
399
+					$this->games = $this->r_rGames();
356 400
 				}
357
-				else $this->games = $this->r_rGames();
358 401
 				break;
359 402
 		}
360 403
 		return $this->games;
@@ -366,8 +409,11 @@  discard block
 block discarded – undo
366 409
 	}
367 410
 	public function addGame(Game ...$games){
368 411
 		foreach ($game as $game) {
369
-			if ($game instanceof Game) $this->games[] = $game;
370
-			else throw new Exception('Trying to add game which is not instance of Game object.');
412
+			if ($game instanceof Game) {
413
+				$this->games[] = $game;
414
+			} else {
415
+				throw new Exception('Trying to add game which is not instance of Game object.');
416
+			}
371 417
 		}
372 418
 		return $this;
373 419
 	}
@@ -395,21 +441,30 @@  discard block
 block discarded – undo
395 441
 				$teams[$team->id] = 0;
396 442
 			}
397 443
 			foreach (end($this->games)->getTeams() as $team) {
398
-				if (!isset($teams[$team->id])) $teams[$team->id] = 4;
399
-				else $teams[$team->id] += 4;
444
+				if (!isset($teams[$team->id])) {
445
+					$teams[$team->id] = 4;
446
+				} else {
447
+					$teams[$team->id] += 4;
448
+				}
400 449
 			}
401 450
 			$g = prev($this->games);
402 451
 			if ($g instanceof Game) {
403 452
 				foreach ($g->getTeams() as $team) {
404
-					if (!isset($teams[$team->id])) $teams[$team->id] = 2;
405
-					else $teams[$team->id] += 2;
453
+					if (!isset($teams[$team->id])) {
454
+						$teams[$team->id] = 2;
455
+					} else {
456
+						$teams[$team->id] += 2;
457
+					}
406 458
 				}
407 459
 			}
408 460
 			$g = prev($this->games);
409 461
 			if ($g instanceof Game) {
410 462
 				foreach ($g->getTeams() as $team) {
411
-					if (!isset($teams[$team->id])) $teams[$team->id] = 1;
412
-					else $teams[$team->id]++;
463
+					if (!isset($teams[$team->id])) {
464
+						$teams[$team->id] = 1;
465
+					} else {
466
+						$teams[$team->id]++;
467
+					}
413 468
 				}
414 469
 			}
415 470
 
@@ -431,7 +486,9 @@  discard block
 block discarded – undo
431 486
 					break;
432 487
 				}
433 488
 			}
434
-			if ($found) continue;
489
+			if ($found) {
490
+				continue;
491
+			}
435 492
 
436 493
 			// CYCLE 2
437 494
 			// ! TEAM WHICH PLAYED IN LAST TWO GAMES (NOT 6 or 7)
@@ -452,7 +509,9 @@  discard block
 block discarded – undo
452 509
 					break;
453 510
 				}
454 511
 			}
455
-			if ($found) continue;
512
+			if ($found) {
513
+				continue;
514
+			}
456 515
 
457 516
 			// CYCLE 3
458 517
 			// ! TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7)
@@ -483,7 +542,9 @@  discard block
 block discarded – undo
483 542
 					break;
484 543
 				}
485 544
 			}
486
-			if ($found) continue;
545
+			if ($found) {
546
+				continue;
547
+			}
487 548
 
488 549
 			// CYCLE 4
489 550
 			// ! TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7)
@@ -504,7 +565,9 @@  discard block
 block discarded – undo
504 565
 					break;
505 566
 				}
506 567
 			}
507
-			if ($found) continue;
568
+			if ($found) {
569
+				continue;
570
+			}
508 571
 
509 572
 			// CYCLE 5
510 573
 			// TEAMS THAT DIDN'T PLAY IN LAST GAME WILL PLAY THIS GAME (< 4)
@@ -529,7 +592,9 @@  discard block
 block discarded – undo
529 592
 					break;
530 593
 				}
531 594
 			}
532
-			if ($found) continue;
595
+			if ($found) {
596
+				continue;
597
+			}
533 598
 
534 599
 			// CYCLE 6
535 600
 			// FIRST AVAILABLE GAME
@@ -540,7 +605,9 @@  discard block
 block discarded – undo
540 605
 	}
541 606
 	public function r_rGames(array $teams = []) {
542 607
 		$games = [];
543
-		if (count($teams) === 0) $teams = $this->teams;
608
+		if (count($teams) === 0) {
609
+			$teams = $this->teams;
610
+		}
544 611
 		switch ($this->inGame) {
545 612
 			case 2:
546 613
 				$games = circle_genGames2($teams, $this);
@@ -589,7 +656,9 @@  discard block
 block discarded – undo
589 656
 			$game->setResults($results);
590 657
 		}
591 658
 		$return = $this->sortTeams($filters);
592
-		if (!$reset) return $return;
659
+		if (!$reset) {
660
+			return $return;
661
+		}
593 662
 		foreach ($this->getGames() as $game) {
594 663
 			$game->resetResults();
595 664
 		}
@@ -597,13 +666,17 @@  discard block
 block discarded – undo
597 666
 	}
598 667
 	public function resetGames() {
599 668
 		foreach ($this->getGames() as $game) {
600
-			if (isset($game)) $game->resetResults();
669
+			if (isset($game)) {
670
+				$game->resetResults();
671
+			}
601 672
 		}
602 673
 		return $this;
603 674
 	}
604 675
 	public function isPlayed(){
605 676
 		foreach ($this->games as $game) {
606
-			if ((isset($game) || !$this->getSkip()) && !$game->isPlayed()) return false;
677
+			if ((isset($game) || !$this->getSkip()) && !$game->isPlayed()) {
678
+				return false;
679
+			}
607 680
 		}
608 681
 		return true;
609 682
 	}
Please login to merge, or discard this patch.
src/classes/class_progression.php 1 patch
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
 	public function addFilter(...$filters) {
29 29
 		foreach ($filters as $filter) {
30
-			if (!$filter instanceof TeamFilter) throw new Exception('Trying to add filter which is not an instance of TeamFilter.');
30
+			if (!$filter instanceof TeamFilter) {
31
+				throw new Exception('Trying to add filter which is not an instance of TeamFilter.');
32
+			}
31 33
 			$this->filters[] = $filter;
32 34
 		}
33 35
 		$this->filter[] = $filter;
@@ -36,8 +38,11 @@  discard block
 block discarded – undo
36 38
 
37 39
 	public function progress() {
38 40
 		$teams = $this->from->sortTeams($this->filters);
39
-		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len == null ? count($teams) : $this->len));
40
-		else $next = $teams;
41
+		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) {
42
+			$next = array_splice($teams, $this->start, ($this->len == null ? count($teams) : $this->len));
43
+		} else {
44
+			$next = $teams;
45
+		}
41 46
 		$this->from->addProgressed($next);
42 47
 		$this->to->addTeam($next);
43 48
 		return $this;
@@ -45,8 +50,11 @@  discard block
 block discarded – undo
45 50
 
46 51
 	public function progressBlank(){
47 52
 		$teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters);
48
-		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len == null ? count($teams) : $this->len));
49
-		else $next = $teams;
53
+		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) {
54
+			$next = array_splice($teams, $this->start, ($this->len == null ? count($teams) : $this->len));
55
+		} else {
56
+			$next = $teams;
57
+		}
50 58
 		$this->from->addProgressed($next);
51 59
 		$i = 1;
52 60
 		foreach ($next as $team) {
Please login to merge, or discard this patch.
src/classes/class_round.php 1 patch
Braces   +32 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,8 +25,11 @@  discard block
 block discarded – undo
25 25
 
26 26
 	public function addGroup(Group ...$groups){
27 27
 		foreach ($groups as $group) {
28
-			if ($group instanceof Group) $this->groups[] = $group;
29
-			else throw new Exception('Trying to add group which is not an instance of Group class.');
28
+			if ($group instanceof Group) {
29
+				$this->groups[] = $group;
30
+			} else {
31
+				throw new Exception('Trying to add group which is not an instance of Group class.');
32
+			}
30 33
 		}
31 34
 		return $this;
32 35
 	}
@@ -77,7 +80,9 @@  discard block
 block discarded – undo
77 80
 		while ($g > 0) {
78 81
 			foreach ($games as $key => $group) {
79 82
 				$this->games[] = array_shift($games[$key]);
80
-				if (count($games[$key]) === 0) unset($games[$key]);
83
+				if (count($games[$key]) === 0) {
84
+					unset($games[$key]);
85
+				}
81 86
 				$g--;
82 87
 			}
83 88
 		}
@@ -88,7 +93,9 @@  discard block
 block discarded – undo
88 93
 	}
89 94
 	public function isPlayed(){
90 95
 		foreach ($this->groups as $group) {
91
-			if (!$group->isPlayed()) return false;
96
+			if (!$group->isPlayed()) {
97
+				return false;
98
+			}
92 99
 		}
93 100
 		return true;
94 101
 	}
@@ -97,10 +104,11 @@  discard block
 block discarded – undo
97 104
 		foreach ($teams as $team) {
98 105
 			if ($team instanceof Team)  {
99 106
 				$this->teams[] = $team;
100
-			}
101
-			elseif (gettype($team) === 'array') {
107
+			} elseif (gettype($team) === 'array') {
102 108
 				foreach ($team as $team2) {
103
-					if ($team2 instanceof Team) $this->teams[] = $team2;
109
+					if ($team2 instanceof Team) {
110
+						$this->teams[] = $team2;
111
+					}
104 112
 					$team2->groupResults[$this->id] = [
105 113
 						'group' => $this,
106 114
 						'points' => 0,
@@ -112,8 +120,9 @@  discard block
 block discarded – undo
112 120
 						'third'  => 0
113 121
 					];
114 122
 				}
123
+			} else {
124
+				throw new Exception('Trying to add team which is not an instance of Team class');
115 125
 			}
116
-			else throw new Exception('Trying to add team which is not an instance of Team class');
117 126
 		}
118 127
 		return $this;
119 128
 	}
@@ -123,7 +132,9 @@  discard block
 block discarded – undo
123 132
 		return $t;
124 133
 	}
125 134
 	public function getTeams() {
126
-		if (count($this->teams) > 0) return $this->teams;
135
+		if (count($this->teams) > 0) {
136
+			return $this->teams;
137
+		}
127 138
 		$teams = [];
128 139
 		foreach ($this->groups as $group) {
129 140
 			$teams = array_merge($teams, $group->getTeams());
@@ -134,7 +145,9 @@  discard block
 block discarded – undo
134 145
 
135 146
 	public function splitTeams(...$groups) {
136 147
 
137
-		if (count($groups) === 0) $groups = $this->getGroups();
148
+		if (count($groups) === 0) {
149
+			$groups = $this->getGroups();
150
+		}
138 151
 
139 152
 		foreach ($groups as $key => $value) {
140 153
 			if (gettype($value) === 'array') {
@@ -149,7 +162,9 @@  discard block
 block discarded – undo
149 162
 		while (count($teams) > 0) {
150 163
 			foreach ($groups as $group) {
151 164
 				if ($group instanceof Group) {
152
-					if (count($teams) > 0) $group->addTeam(array_shift($teams));
165
+					if (count($teams) > 0) {
166
+						$group->addTeam(array_shift($teams));
167
+					}
153 168
 				}
154 169
 			}
155 170
 		}
@@ -164,7 +179,9 @@  discard block
 block discarded – undo
164 179
 	}
165 180
 
166 181
 	public function progressBlank(){
167
-		if (!$this->isPlayed()) $this->simulate();
182
+		if (!$this->isPlayed()) {
183
+			$this->simulate();
184
+		}
168 185
 		foreach ($this->groups as $group) {
169 186
 			$group->progressBlank();
170 187
 		}
@@ -173,7 +190,9 @@  discard block
 block discarded – undo
173 190
 
174 191
 	public function simulate() {
175 192
 		foreach ($this->groups as $group) {
176
-			if ($group->isPlayed()) continue;
193
+			if ($group->isPlayed()) {
194
+				continue;
195
+			}
177 196
 			$group->simulate([], false);
178 197
 		}
179 198
 		return $this;
Please login to merge, or discard this patch.
src/classes/class_tournament.php 1 patch
Braces   +39 added lines, -24 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
 	}
@@ -119,10 +125,11 @@  discard block
 block discarded – undo
119 125
 		foreach ($teams as $team) {
120 126
 			if ($team instanceof Team)  {
121 127
 				$this->teams[] = $team;
122
-			}
123
-			elseif (gettype($team) === 'array') {
128
+			} elseif (gettype($team) === 'array') {
124 129
 				foreach ($team as $team2) {
125
-					if ($team2 instanceof Team) $this->teams[] = $team2;
130
+					if ($team2 instanceof Team) {
131
+						$this->teams[] = $team2;
132
+					}
126 133
 					$team2->groupResults[$this->id] = [
127 134
 						'group' => $this,
128 135
 						'points' => 0,
@@ -134,8 +141,9 @@  discard block
 block discarded – undo
134 141
 						'third'  => 0
135 142
 					];
136 143
 				}
144
+			} else {
145
+				throw new Exception('Trying to add team which is not an instance of Team class');
137 146
 			}
138
-			else throw new Exception('Trying to add team which is not an instance of Team class');
139 147
 		}
140 148
 		return $this;
141 149
 	}
@@ -145,7 +153,9 @@  discard block
 block discarded – undo
145 153
 		return $t;
146 154
 	}
147 155
 	public function getTeams() {
148
-		if (count($this->teams) > 0) return $this->teams;
156
+		if (count($this->teams) > 0) {
157
+			return $this->teams;
158
+		}
149 159
 		$teams = [];
150 160
 		foreach ($this->categories as $category) {
151 161
 			$teams = array_merge($teams, $category->getTeams());
@@ -167,7 +177,9 @@  discard block
 block discarded – undo
167 177
 
168 178
 	public function splitTeams(...$wheres) {
169 179
 
170
-		if (count($wheres) === 0) $wheres = array_merge($this->getRounds(), $this->getCategories());
180
+		if (count($wheres) === 0) {
181
+			$wheres = array_merge($this->getRounds(), $this->getCategories());
182
+		}
171 183
 
172 184
 		foreach ($wheres as $key => $value) {
173 185
 			if (gettype($value) === 'array') {
@@ -182,10 +194,13 @@  discard block
 block discarded – undo
182 194
 		while (count($teams) > 0) {
183 195
 			foreach ($wheres as $where) {
184 196
 				if ($where instanceof Round) {
185
-					if (count($teams) > 0) $where->addTeam(array_shift($teams));
186
-				}
187
-				elseif ($where instanceof Category) {
188
-					if (count($teams) > 0) $where->addTeam(array_shift($teams));
197
+					if (count($teams) > 0) {
198
+						$where->addTeam(array_shift($teams));
199
+					}
200
+				} elseif ($where instanceof Category) {
201
+					if (count($teams) > 0) {
202
+						$where->addTeam(array_shift($teams));
203
+					}
189 204
 				}
190 205
 			}
191 206
 		}
@@ -201,8 +216,7 @@  discard block
 block discarded – undo
201 216
 			foreach ($this->categories as $category) {
202 217
 				$games = array_merge($games, $category->genGamesSimulate());
203 218
 			}
204
-		}
205
-		elseif (count($this->rounds) > 0) {
219
+		} elseif (count($this->rounds) > 0) {
206 220
 			foreach ($this->rounds as $round) {
207 221
 				$games = array_merge($games, $round->genGames());
208 222
 				$round->simulate()->progressBlank();
@@ -210,11 +224,12 @@  discard block
 block discarded – undo
210 224
 			foreach ($this->rounds as $round) {
211 225
 				$round->resetGames();
212 226
 			}
213
-		}
214
-		else {
227
+		} else {
215 228
 			throw new Exception('There are no rounds or categories to simulate games from.');
216 229
 		}
217
-		if ($returnTime) return $this->getTournamentTime();
230
+		if ($returnTime) {
231
+			return $this->getTournamentTime();
232
+		}
218 233
 		return $games;
219 234
 	}
220 235
 	public function genGamesSimulateReal(bool $returnTime = false) {
@@ -223,18 +238,18 @@  discard block
 block discarded – undo
223 238
 			foreach ($this->categories as $category) {
224 239
 				$games = array_merge($games, $category->genGamesSimulate());
225 240
 			}
226
-		}
227
-		elseif (count($this->rounds) > 0) {
241
+		} elseif (count($this->rounds) > 0) {
228 242
 			foreach ($this->rounds as $round) {
229 243
 				$games = array_merge($games, $round->genGames());
230 244
 				$round->simulate();
231 245
 				$round->progress();
232 246
 			}
233
-		}
234
-		else {
247
+		} else {
235 248
 			throw new Exception('There are no rounds or categories to simulate games from.');
236 249
 		}
237
-		if ($returnTime) return $this->getTournamentTime();
250
+		if ($returnTime) {
251
+			return $this->getTournamentTime();
252
+		}
238 253
 		return $games;
239 254
 	}
240 255
 
Please login to merge, or discard this patch.