@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | // CYCLE 6 |
71 | 71 | // FIRST AVAILABLE GAME |
72 | - $this->moveCalculatedGames(array_shift($games),$teams); |
|
72 | + $this->moveCalculatedGames(array_shift($games), $teams); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return $this->games; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | private function cycle1(array &$games, array &$teams) { |
80 | 80 | $found = false; |
81 | 81 | foreach ($games as $key => $game) { |
82 | - if ($this->orderCheckTeamsVal($game, $teams, [4,5,6,7])) { |
|
83 | - $this->moveCalculatedGames($game,$teams); |
|
82 | + if ($this->orderCheckTeamsVal($game, $teams, [4, 5, 6, 7])) { |
|
83 | + $this->moveCalculatedGames($game, $teams); |
|
84 | 84 | unset($games[$key]); |
85 | 85 | $found = true; |
86 | 86 | break; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | private function cycle2(array &$games, array &$teams) { |
93 | 93 | $found = false; |
94 | 94 | foreach ($games as $key => $game) { |
95 | - if ($this->orderCheckTeamsVal($game, $teams, [6,7])) { |
|
96 | - $this->moveCalculatedGames($game,$teams); |
|
95 | + if ($this->orderCheckTeamsVal($game, $teams, [6, 7])) { |
|
96 | + $this->moveCalculatedGames($game, $teams); |
|
97 | 97 | unset($games[$key]); |
98 | 98 | $found = true; |
99 | 99 | break; |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | private function cycle3(array &$games, array &$teams) { |
107 | 107 | $found = false; |
108 | 108 | foreach ($games as $key => $game) { |
109 | - if ($this->orderCheckTeamsVal($game, $teams, [7], [1,2,3])) { |
|
110 | - $this->moveCalculatedGames($game,$teams); |
|
109 | + if ($this->orderCheckTeamsVal($game, $teams, [7], [1, 2, 3])) { |
|
110 | + $this->moveCalculatedGames($game, $teams); |
|
111 | 111 | unset($games[$key]); |
112 | 112 | $found = true; |
113 | 113 | break; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $found = false; |
121 | 121 | foreach ($games as $key => $game) { |
122 | 122 | if ($this->orderCheckTeamsVal($game, $teams, [7])) { |
123 | - $this->moveCalculatedGames($game,$teams); |
|
123 | + $this->moveCalculatedGames($game, $teams); |
|
124 | 124 | unset($games[$key]); |
125 | 125 | $found = true; |
126 | 126 | break; |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | private function cycle5(array &$games, array &$teams) { |
133 | 133 | $found = false; |
134 | 134 | foreach ($games as $key => $game) { |
135 | - if ($this->orderCheckTeamsVal($game, $teams, [], [1,2,3])) { |
|
136 | - $this->moveCalculatedGames($game,$teams); |
|
135 | + if ($this->orderCheckTeamsVal($game, $teams, [], [1, 2, 3])) { |
|
136 | + $this->moveCalculatedGames($game, $teams); |
|
137 | 137 | unset($games[$key]); |
138 | 138 | $found = true; |
139 | 139 | break; |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | $games = $this->group->getGames(); |
38 | 38 | |
39 | - if (count($games) <= 4) return $games; |
|
39 | + if (count($games) <= 4) { |
|
40 | + return $games; |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $this->games = []; |
42 | 44 | |
@@ -48,24 +50,34 @@ discard block |
||
48 | 50 | while (count($games) > 0) { |
49 | 51 | // CYCLE 1 |
50 | 52 | // TEAM WHICH DIDN'T PLAY IN LAST GAME (< 4) |
51 | - if ($this->cycle1($games, $teams)) continue; |
|
53 | + if ($this->cycle1($games, $teams)) { |
|
54 | + continue; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | // CYCLE 2 |
54 | 58 | // NOT TEAM WHICH PLAYED IN LAST TWO GAMES (NOT 6 or 7) |
55 | - if ($this->cycle2($games, $teams)) continue; |
|
59 | + if ($this->cycle2($games, $teams)) { |
|
60 | + continue; |
|
61 | + } |
|
56 | 62 | |
57 | 63 | // CYCLE 3 |
58 | 64 | // NOT TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7) |
59 | 65 | // TEAMS THAT DIDN'T PLAY IN LAST GAME WILL PLAY THIS GAME (< 4) |
60 | - if ($this->cycle3($games, $teams)) continue; |
|
66 | + if ($this->cycle3($games, $teams)) { |
|
67 | + continue; |
|
68 | + } |
|
61 | 69 | |
62 | 70 | // CYCLE 4 |
63 | 71 | // NOT TEAM WHICH PLAYED IN LAST THREE GAMES (NOT 7) |
64 | - if ($this->cycle4($games, $teams)) continue; |
|
72 | + if ($this->cycle4($games, $teams)) { |
|
73 | + continue; |
|
74 | + } |
|
65 | 75 | |
66 | 76 | // CYCLE 5 |
67 | 77 | // TEAMS THAT DIDN'T PLAY IN LAST GAME WILL PLAY THIS GAME (< 4) |
68 | - if ($this->cycle5($games, $teams)) continue; |
|
78 | + if ($this->cycle5($games, $teams)) { |
|
79 | + continue; |
|
80 | + } |
|
69 | 81 | |
70 | 82 | // CYCLE 6 |
71 | 83 | // FIRST AVAILABLE GAME |
@@ -174,11 +186,17 @@ discard block |
||
174 | 186 | $requiredTeams = array_filter($teams, function($a) use ($required) { return in_array($a, $required); }); |
175 | 187 | |
176 | 188 | foreach ($game->getTeamsIds() as $tid) { |
177 | - if (in_array($teams[$tid], $checkVals)) return false; |
|
178 | - if (isset($requiredTeams[$tid])) unset($requiredTeams[$tid]); |
|
189 | + if (in_array($teams[$tid], $checkVals)) { |
|
190 | + return false; |
|
191 | + } |
|
192 | + if (isset($requiredTeams[$tid])) { |
|
193 | + unset($requiredTeams[$tid]); |
|
194 | + } |
|
179 | 195 | } |
180 | 196 | |
181 | - if (count($requiredTeams) > 0) return false; |
|
197 | + if (count($requiredTeams) > 0) { |
|
198 | + return false; |
|
199 | + } |
|
182 | 200 | |
183 | 201 | return true; |
184 | 202 |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | $this->group = $group; |
19 | 19 | } |
20 | 20 | |
21 | - public function allowSkip(){ |
|
21 | + public function allowSkip() { |
|
22 | 22 | $this->allowSkip = true; |
23 | 23 | return $this; |
24 | 24 | } |
25 | - public function disallowSkip(){ |
|
25 | + public function disallowSkip() { |
|
26 | 26 | $this->allowSkip = false; |
27 | 27 | return $this; |
28 | 28 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | public function setInGame(int $inGame) { |
48 | - if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
48 | + if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
49 | 49 | $this->inGame = $inGame; |
50 | 50 | return $this; |
51 | 51 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | $discard = []; |
121 | 121 | shuffle($teams); |
122 | 122 | $count = count($teams); |
123 | - while (count($teams) % $this->inGame !== 0) { $discard[] = array_shift($teams); } |
|
123 | + while (count($teams)%$this->inGame !== 0) { $discard[] = array_shift($teams); } |
|
124 | 124 | |
125 | 125 | while (count($teams) > 0) { |
126 | 126 | $tInGame = []; |
127 | - for ($i=0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); } |
|
127 | + for ($i = 0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); } |
|
128 | 128 | $this->group->game($tInGame); |
129 | 129 | } |
130 | 130 | |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | public static function circle_genGames2(array $teams = [], \tournamentGenerator\Group $group) { |
166 | 166 | $bracket = []; // ARRAY OF GAMES |
167 | 167 | |
168 | - if (count($teams) % 2 != 0) $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
168 | + if (count($teams)%2 != 0) $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
169 | 169 | |
170 | 170 | shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS |
171 | 171 | |
172 | - for ($i=0; $i < count($teams)-1; $i++) { |
|
172 | + for ($i = 0; $i < count($teams)-1; $i++) { |
|
173 | 173 | $bracket = array_merge($bracket, Generator::circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND |
174 | 174 | |
175 | 175 | $teams = Generator::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | $bracket = []; |
185 | 185 | |
186 | - for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
186 | + for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
187 | 187 | |
188 | 188 | $home = $teams[$i]; |
189 | 189 | $reverse = array_reverse($teams); |
@@ -36,8 +36,11 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | public function setType(/** @scrutinizer ignore-all */ string $type = \TournamentGenerator\Constants::ROUND_ROBIN) { |
39 | - if (in_array($type, \TournamentGenerator\Constants::GroupTypes)) $this->type = $type; |
|
40 | - else throw new \Exception('Unknown group type: '.$type); |
|
39 | + if (in_array($type, \TournamentGenerator\Constants::GroupTypes)) { |
|
40 | + $this->type = $type; |
|
41 | + } else { |
|
42 | + throw new \Exception('Unknown group type: '.$type); |
|
43 | + } |
|
41 | 44 | return $this; |
42 | 45 | } |
43 | 46 | public function getType() { |
@@ -45,7 +48,9 @@ discard block |
||
45 | 48 | } |
46 | 49 | |
47 | 50 | public function setInGame(int $inGame) { |
48 | - if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
51 | + if ($inGame < 2 || $inGame > 4) { |
|
52 | + throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
53 | + } |
|
49 | 54 | $this->inGame = $inGame; |
50 | 55 | return $this; |
51 | 56 | } |
@@ -54,7 +59,9 @@ discard block |
||
54 | 59 | } |
55 | 60 | |
56 | 61 | public function setMaxSize(int $maxSize) { |
57 | - if ($maxSize < 2) throw new \Exception('Max group size has to be at least 2, '.$maxSize.' given'); |
|
62 | + if ($maxSize < 2) { |
|
63 | + throw new \Exception('Max group size has to be at least 2, '.$maxSize.' given'); |
|
64 | + } |
|
58 | 65 | $this->maxSize = $maxSize; |
59 | 66 | return $this; |
60 | 67 | } |
@@ -78,7 +85,9 @@ discard block |
||
78 | 85 | } |
79 | 86 | private function r_rGames(array $teams = []) { |
80 | 87 | $games = []; |
81 | - if (count($teams) === 0) $teams = $this->group->getTeams(); |
|
88 | + if (count($teams) === 0) { |
|
89 | + $teams = $this->group->getTeams(); |
|
90 | + } |
|
82 | 91 | switch ($this->inGame) { |
83 | 92 | case 2: |
84 | 93 | $games = Generator::circle_genGames2($teams, $this->group); |
@@ -98,7 +107,9 @@ discard block |
||
98 | 107 | $lockedTeam = array_shift($teamsB); |
99 | 108 | $gamesTemp = Generator::circle_genGames2($teamsB, $this->group); |
100 | 109 | foreach ($gamesTemp as $game) { |
101 | - if (isset($lockedTeam1)) $game->addTeam($lockedTeam1); |
|
110 | + if (isset($lockedTeam1)) { |
|
111 | + $game->addTeam($lockedTeam1); |
|
112 | + } |
|
102 | 113 | $game->addTeam($lockedTeam); |
103 | 114 | } |
104 | 115 | $games = array_merge($games, $gamesTemp); |
@@ -116,7 +127,9 @@ discard block |
||
116 | 127 | return $games; |
117 | 128 | } |
118 | 129 | private function two_twoGames(array $teams = []) { |
119 | - if (count($teams) === 0) $teams = $this->group->getTeams(); |
|
130 | + if (count($teams) === 0) { |
|
131 | + $teams = $this->group->getTeams(); |
|
132 | + } |
|
120 | 133 | $discard = []; |
121 | 134 | shuffle($teams); |
122 | 135 | $count = count($teams); |
@@ -128,13 +141,17 @@ discard block |
||
128 | 141 | $this->group->game($tInGame); |
129 | 142 | } |
130 | 143 | |
131 | - if (count($discard) > 0 && !$this->allowSkip) throw new \Exception('Couldn\'t make games with all teams. Expected k*'.$this->inGame.' teams '.$count.' teams given - discarting '.count($discard).' teams ('.implode(', ', $discard).') in group '.$this->group.' - allow skip '.($this->allowSkip ? 'True' : 'False')); |
|
144 | + if (count($discard) > 0 && !$this->allowSkip) { |
|
145 | + throw new \Exception('Couldn\'t make games with all teams. Expected k*'.$this->inGame.' teams '.$count.' teams given - discarting '.count($discard).' teams ('.implode(', ', $discard).') in group '.$this->group.' - allow skip '.($this->allowSkip ? 'True' : 'False')); |
|
146 | + } |
|
132 | 147 | |
133 | 148 | return $this; |
134 | 149 | } |
135 | 150 | private function cond_splitGames(array $teams = []) { |
136 | 151 | $games = []; |
137 | - if (count($teams) === 0) $teams = $this->group->getTeams(); |
|
152 | + if (count($teams) === 0) { |
|
153 | + $teams = $this->group->getTeams(); |
|
154 | + } |
|
138 | 155 | |
139 | 156 | if (count($teams) > $this->maxSize) { |
140 | 157 | $groups = array_chunk($teams, /** @scrutinizer ignore-type */ ceil(count($teams)/ceil(count($teams)/$this->maxSize))); // SPLIT TEAMS INTO GROUP OF MAXIMUM SIZE OF $this->maxSize |
@@ -144,7 +161,9 @@ discard block |
||
144 | 161 | while ($g > 0) { |
145 | 162 | foreach ($games as $key => $group) { |
146 | 163 | $this->group->addGame(array_shift($games[$key])); |
147 | - if (count($games[$key]) === 0) unset($games[$key]); |
|
164 | + if (count($games[$key]) === 0) { |
|
165 | + unset($games[$key]); |
|
166 | + } |
|
148 | 167 | $g--; |
149 | 168 | } |
150 | 169 | } |
@@ -165,7 +184,10 @@ discard block |
||
165 | 184 | public static function circle_genGames2(array $teams = [], \tournamentGenerator\Group $group) { |
166 | 185 | $bracket = []; // ARRAY OF GAMES |
167 | 186 | |
168 | - if (count($teams) % 2 != 0) $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
187 | + if (count($teams) % 2 != 0) { |
|
188 | + $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; |
|
189 | + } |
|
190 | + // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
169 | 191 | |
170 | 192 | shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS |
171 | 193 | |
@@ -189,7 +211,10 @@ discard block |
||
189 | 211 | $reverse = array_reverse($teams); |
190 | 212 | $away = $reverse[$i]; |
191 | 213 | |
192 | - if (($home == \TournamentGenerator\Constants::DUMMY_TEAM || $away == \TournamentGenerator\Constants::DUMMY_TEAM)) continue; // SKIP WHEN DUMMY_TEAM IS PRESENT |
|
214 | + if (($home == \TournamentGenerator\Constants::DUMMY_TEAM || $away == \TournamentGenerator\Constants::DUMMY_TEAM)) { |
|
215 | + continue; |
|
216 | + } |
|
217 | + // SKIP WHEN DUMMY_TEAM IS PRESENT |
|
193 | 218 | |
194 | 219 | $bracket[] = new \TournamentGenerator\Game([$home, $away], $group); |
195 | 220 |
@@ -30,7 +30,7 @@ |
||
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]); |
@@ -12,7 +12,9 @@ |
||
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'); |
@@ -16,7 +16,7 @@ discard block |
||
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 |
||
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 |
@@ -13,7 +13,9 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -31,7 +31,7 @@ discard block |
||
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->getId(); |
@@ -41,7 +41,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | /** |
21 | - * @var array $ids Stores ids of groups get scores and points from |
|
22 | - */ |
|
21 | + * @var array $ids Stores ids of groups get scores and points from |
|
22 | + */ |
|
23 | 23 | protected static $ids = []; |
24 | 24 | |
25 | 25 | /** |
26 | - * Sort teams in group by defined ordering type |
|
27 | - * |
|
28 | - * @param array &$teams Array of teams to be sorted |
|
29 | - * @param \TournamentGenerator\Group $group Group to get the results from |
|
30 | - * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
31 | - * |
|
32 | - * @return array Sorted array of teams |
|
33 | - */ |
|
26 | + * Sort teams in group by defined ordering type |
|
27 | + * |
|
28 | + * @param array &$teams Array of teams to be sorted |
|
29 | + * @param \TournamentGenerator\Group $group Group to get the results from |
|
30 | + * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
31 | + * |
|
32 | + * @return array Sorted array of teams |
|
33 | + */ |
|
34 | 34 | public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) { |
35 | 35 | if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
36 | 36 | |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Sort teams in round by defined ordering type |
|
53 | - * |
|
54 | - * @param array &$teams Array of teams to be sorted |
|
55 | - * @param \TournamentGenerator\Round $round Round to get the results from |
|
56 | - * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
57 | - * |
|
58 | - * @return array Sorted array of teams |
|
59 | - */ |
|
52 | + * Sort teams in round by defined ordering type |
|
53 | + * |
|
54 | + * @param array &$teams Array of teams to be sorted |
|
55 | + * @param \TournamentGenerator\Round $round Round to get the results from |
|
56 | + * @param string $ordering What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE) |
|
57 | + * |
|
58 | + * @return array Sorted array of teams |
|
59 | + */ |
|
60 | 60 | public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) { |
61 | 61 | if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
62 | 62 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | - * Sorter function for uasort by points |
|
79 | - */ |
|
78 | + * Sorter function for uasort by points |
|
79 | + */ |
|
80 | 80 | private static function sortTeamsByPoints($a, $b) { |
81 | 81 | $groupsIds = self::$ids; |
82 | 82 | if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
85 | 85 | } |
86 | 86 | /** |
87 | - * Sorter function for uasort by score |
|
88 | - */ |
|
87 | + * Sorter function for uasort by score |
|
88 | + */ |
|
89 | 89 | private static function sortTeamsByScore($a, $b) { |
90 | 90 | $groupsIds = self::$ids; |
91 | 91 | if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | * @return array Sorted array of teams |
33 | 33 | */ |
34 | 34 | public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) { |
35 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
35 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
36 | + throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | self::$ids = [$group->getId()]; |
38 | 40 | |
@@ -58,7 +60,9 @@ discard block |
||
58 | 60 | * @return array Sorted array of teams |
59 | 61 | */ |
60 | 62 | public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) { |
61 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
63 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
64 | + throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
65 | + } |
|
62 | 66 | |
63 | 67 | self::$ids = $round->getGroupsIds(); |
64 | 68 | |
@@ -79,8 +83,12 @@ discard block |
||
79 | 83 | */ |
80 | 84 | private static function sortTeamsByPoints($a, $b) { |
81 | 85 | $groupsIds = self::$ids; |
82 | - if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
|
83 | - if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
|
86 | + if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) { |
|
87 | + return 0; |
|
88 | + } |
|
89 | + if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) { |
|
90 | + return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
|
91 | + } |
|
84 | 92 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
85 | 93 | } |
86 | 94 | /** |
@@ -88,7 +96,9 @@ discard block |
||
88 | 96 | */ |
89 | 97 | private static function sortTeamsByScore($a, $b) { |
90 | 98 | $groupsIds = self::$ids; |
91 | - if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
|
99 | + if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) { |
|
100 | + return 0; |
|
101 | + } |
|
92 | 102 | return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
93 | 103 | } |
94 | 104 |
@@ -80,10 +80,10 @@ |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * $results = array ( |
|
84 | - * * team->getId() => team->score |
|
85 | - * ) |
|
86 | - */ |
|
83 | + * $results = array ( |
|
84 | + * * team->getId() => team->score |
|
85 | + * ) |
|
86 | + */ |
|
87 | 87 | public function setResults(array $results = []) { |
88 | 88 | if (count($this->results) === 0) $this->resetResults(); |
89 | 89 | arsort($results); |
@@ -66,14 +66,14 @@ discard block |
||
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->getId(); }, $this->teams); |
|
72 | + public function getTeamsIds() { |
|
73 | + return array_map(function($a) { return $a->getId(); }, $this->teams); |
|
74 | 74 | } |
75 | 75 | public function getTeam($id) { |
76 | - $key = array_search($id, array_map(function($a){ return $a->getId();}, $this->teams)); |
|
76 | + $key = array_search($id, array_map(function($a) { return $a->getId(); }, $this->teams)); |
|
77 | 77 | return ($key !== false ? $this->teams[$key] : false); |
78 | 78 | } |
79 | 79 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | private function setResults2($i, $score, $results, $team) { |
113 | - if (count(array_filter($results, function($a) use ($score){return $a === $score;})) > 1) { |
|
113 | + if (count(array_filter($results, function($a) use ($score){return $a === $score; })) > 1) { |
|
114 | 114 | $this->drawIds[] = $team->getId(); |
115 | 115 | $team->addDraw($this->group->getId()); |
116 | 116 | $this->results[$team->getId()] += ['points' => $this->group->getDrawPoints(), 'type' => 'draw']; |
@@ -33,11 +33,15 @@ discard block |
||
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 |
||
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(){ |
@@ -83,14 +91,20 @@ discard block |
||
83 | 91 | * ) |
84 | 92 | */ |
85 | 93 | public function setResults(array $results = []) { |
86 | - if (count($this->results) === 0) $this->resetResults(); |
|
94 | + if (count($this->results) === 0) { |
|
95 | + $this->resetResults(); |
|
96 | + } |
|
87 | 97 | arsort($results); |
88 | 98 | $inGame = /** @scrutinizer ignore-call */ $this->group->getInGame(); |
89 | 99 | $i = 1; |
90 | 100 | foreach ($results as $id => $score) { |
91 | - if (!is_numeric($score)) throw new \TypeError('Score passed to TournamentGenerator\Game::setResults() must be of the type numeric, '.gettype($score).' given'); |
|
101 | + if (!is_numeric($score)) { |
|
102 | + throw new \TypeError('Score passed to TournamentGenerator\Game::setResults() must be of the type numeric, '.gettype($score).' given'); |
|
103 | + } |
|
92 | 104 | $team = $this->getTeam($id); |
93 | - if (!$team instanceof Team) throw new \Exception('Couldn\'t find team with id of "'.$id.'"'); |
|
105 | + if (!$team instanceof Team) { |
|
106 | + throw new \Exception('Couldn\'t find team with id of "'.$id.'"'); |
|
107 | + } |
|
94 | 108 | $this->results[$team->getId()] = ['score' => $score]; |
95 | 109 | $team->addScore($score); |
96 | 110 | switch ($inGame) { |
@@ -114,13 +128,11 @@ discard block |
||
114 | 128 | $this->drawIds[] = $team->getId(); |
115 | 129 | $team->addDraw($this->group->getId()); |
116 | 130 | $this->results[$team->getId()] += ['points' => $this->group->getDrawPoints(), 'type' => 'draw']; |
117 | - } |
|
118 | - elseif ($i === 1) { |
|
131 | + } elseif ($i === 1) { |
|
119 | 132 | $this->winId = $team->getId(); |
120 | 133 | $team->addWin($this->group->getId()); |
121 | 134 | $this->results[$team->getId()] += ['points' => $this->group->getWinPoints(), 'type' => 'win']; |
122 | - } |
|
123 | - else { |
|
135 | + } else { |
|
124 | 136 | $this->lossId = $team->getId(); |
125 | 137 | $team->addLoss($this->group->getId()); |
126 | 138 | $this->results[$team->getId()] += ['points' => $this->group->getLostPoints(), 'type' => 'loss']; |
@@ -220,7 +232,9 @@ discard block |
||
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 | } |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | private static function calcSum(\TournamentGenerator\Team $team, array $groupsId) { |
53 | 53 | $sum = 0; |
54 | 54 | foreach ($groupsId as $id) { |
55 | - if (isset($team->groupResults[$id])) $sum += $team->groupResults[$id][self::$what]; |
|
55 | + if (isset($team->groupResults[$id])) { |
|
56 | + $sum += $team->groupResults[$id][self::$what]; |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | return $sum; |
58 | 60 | } |
@@ -62,12 +64,16 @@ discard block |
||
62 | 64 | $games = $team->getGames(null, reset($groupsId)); |
63 | 65 | foreach ($games as $game) { |
64 | 66 | $results = $game->getResults()[$team->getId()]; |
65 | - if (($results[self::$what] > $max || $max === null)) $max = $results[self::$what]; |
|
67 | + if (($results[self::$what] > $max || $max === null)) { |
|
68 | + $max = $results[self::$what]; |
|
69 | + } |
|
66 | 70 | } |
67 | 71 | return $max; |
68 | 72 | } |
69 | 73 | foreach ($groupsId as $id) { |
70 | - if (isset($team->groupResults[$id]) && ($team->groupResults[$id][self::$what] > $max || $max === null)) $max = $team->groupResults[$id][self::$what]; |
|
74 | + if (isset($team->groupResults[$id]) && ($team->groupResults[$id][self::$what] > $max || $max === null)) { |
|
75 | + $max = $team->groupResults[$id][self::$what]; |
|
76 | + } |
|
71 | 77 | } |
72 | 78 | return $max; |
73 | 79 | } |
@@ -77,12 +83,16 @@ discard block |
||
77 | 83 | $games = $team->getGames(null, reset($groupsId)); |
78 | 84 | foreach ($games as $game) { |
79 | 85 | $results = $game->getResults()[$team->getId()]; |
80 | - if (($results[self::$what] < $min || $min === null)) $min = $results[self::$what]; |
|
86 | + if (($results[self::$what] < $min || $min === null)) { |
|
87 | + $min = $results[self::$what]; |
|
88 | + } |
|
81 | 89 | } |
82 | 90 | return $min; |
83 | 91 | } |
84 | 92 | foreach ($groupsId as $id) { |
85 | - if (isset($team->groupResults[$id]) && ($team->groupResults[$id][self::$what] < $min || $min === null)) $min = $team->groupResults[$id][self::$what]; |
|
93 | + if (isset($team->groupResults[$id]) && ($team->groupResults[$id][self::$what] < $min || $min === null)) { |
|
94 | + $min = $team->groupResults[$id][self::$what]; |
|
95 | + } |
|
86 | 96 | } |
87 | 97 | return $min; |
88 | 98 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $this->setId(isset($id) ? $id : uniqid()); |
19 | 19 | } |
20 | 20 | |
21 | - public function addGroup(Group ...$groups){ |
|
21 | + public function addGroup(Group ...$groups) { |
|
22 | 22 | foreach ($groups as $group) { |
23 | 23 | $this->groups[] = $group; |
24 | 24 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $this->groups[] = $g->setSkip($this->allowSkip); |
30 | 30 | return $g; |
31 | 31 | } |
32 | - public function getGroups(){ |
|
32 | + public function getGroups() { |
|
33 | 33 | $this->orderGroups(); |
34 | 34 | return $this->groups; |
35 | 35 | } |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | return array_map(function($a) { return $a->getId(); }, $this->groups); |
39 | 39 | } |
40 | 40 | public function orderGroups() { |
41 | - usort($this->groups, function($a, $b){ |
|
42 | - return $a->getOrder() - $b->getOrder(); |
|
41 | + usort($this->groups, function($a, $b) { |
|
42 | + return $a->getOrder()-$b->getOrder(); |
|
43 | 43 | }); |
44 | 44 | return $this->groups; |
45 | 45 | } |
46 | 46 | |
47 | - public function allowSkip(){ |
|
47 | + public function allowSkip() { |
|
48 | 48 | $this->allowSkip = true; |
49 | 49 | return $this; |
50 | 50 | } |
51 | - public function disallowSkip(){ |
|
51 | + public function disallowSkip() { |
|
52 | 52 | $this->allowSkip = false; |
53 | 53 | return $this; |
54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return $this->allowSkip; |
61 | 61 | } |
62 | 62 | |
63 | - public function genGames(){ |
|
63 | + public function genGames() { |
|
64 | 64 | foreach ($this->groups as $group) { |
65 | 65 | $group->genGames(); |
66 | 66 | $this->games = array_merge($this->games, $group->orderGames()); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function getGames() { |
71 | 71 | return $this->games; |
72 | 72 | } |
73 | - public function isPlayed(){ |
|
73 | + public function isPlayed() { |
|
74 | 74 | if (count($this->games) === 0) return false; |
75 | 75 | foreach ($this->groups as $group) { |
76 | 76 | if (!$group->isPlayed()) return false; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - public function progress(bool $blank = false){ |
|
125 | + public function progress(bool $blank = false) { |
|
126 | 126 | foreach ($this->groups as $group) { |
127 | 127 | $group->progress($blank); |
128 | 128 | } |
@@ -71,9 +71,13 @@ discard block |
||
71 | 71 | return $this->games; |
72 | 72 | } |
73 | 73 | public function isPlayed(){ |
74 | - if (count($this->games) === 0) return false; |
|
74 | + if (count($this->games) === 0) { |
|
75 | + return false; |
|
76 | + } |
|
75 | 77 | foreach ($this->groups as $group) { |
76 | - if (!$group->isPlayed()) return false; |
|
78 | + if (!$group->isPlayed()) { |
|
79 | + return false; |
|
80 | + } |
|
77 | 81 | } |
78 | 82 | return true; |
79 | 83 | } |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | } |
98 | 102 | $this->teams = $teams; |
99 | 103 | } |
100 | - if ($ordered) $teams = $this->sortTeams($ordering); |
|
104 | + if ($ordered) { |
|
105 | + $teams = $this->sortTeams($ordering); |
|
106 | + } |
|
101 | 107 | |
102 | 108 | // APPLY FILTERS |
103 | 109 | $filter = new Filter($this->getGroups(), $filters); |
@@ -116,14 +122,18 @@ discard block |
||
116 | 122 | |
117 | 123 | public function splitTeams(Group ...$groups) { |
118 | 124 | |
119 | - if (count($groups) === 0) $groups = $this->getGroups(); |
|
125 | + if (count($groups) === 0) { |
|
126 | + $groups = $this->getGroups(); |
|
127 | + } |
|
120 | 128 | |
121 | 129 | $teams = $this->getTeams(); |
122 | 130 | shuffle($teams); |
123 | 131 | |
124 | 132 | while (count($teams) > 0) { |
125 | 133 | foreach ($groups as $group) { |
126 | - if (count($teams) > 0) $group->addTeam(array_shift($teams)); |
|
134 | + if (count($teams) > 0) { |
|
135 | + $group->addTeam(array_shift($teams)); |
|
136 | + } |
|
127 | 137 | } |
128 | 138 | } |
129 | 139 | return $this; |