@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | if ($a->groupResults[$group->id]["points"] === $b->groupResults[$group->id]["points"]) return ($a->groupResults[$group->id]["score"] > $b->groupResults[$group->id]["score"] ? -1 : 1); |
| 19 | 19 | return ($a->groupResults[$group->id]["points"] > $b->groupResults[$group->id]["points"] ? -1 : 1); |
| 20 | 20 | }); |
| 21 | - break;} |
|
| 21 | + break; } |
|
| 22 | 22 | case \TournamentGenerator\Constants::SCORE:{ |
| 23 | 23 | uasort($teams, function($a, $b) use ($group) { |
| 24 | 24 | if ($a->groupResults[$group->id]["score"] === $b->groupResults[$group->id]["score"]) return 0; |
| 25 | 25 | return ($a->groupResults[$group->id]["score"] > $b->groupResults[$group->id]["score"] ? -1 : 1); |
| 26 | 26 | }); |
| 27 | - break;} |
|
| 27 | + break; } |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return $teams; |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
| 42 | 42 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
| 43 | 43 | }); |
| 44 | - break;} |
|
| 44 | + break; } |
|
| 45 | 45 | case \TournamentGenerator\Constants::SCORE:{ |
| 46 | 46 | uasort($teams, function($a, $b) use ($groupsIds) { |
| 47 | 47 | if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
| 48 | 48 | return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
| 49 | 49 | }); |
| 50 | - break;} |
|
| 50 | + break; } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | return $teams; |
@@ -9,19 +9,27 @@ discard block |
||
| 9 | 9 | { |
| 10 | 10 | |
| 11 | 11 | public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) { |
| 12 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
| 12 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
| 13 | + throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
| 14 | + } |
|
| 13 | 15 | |
| 14 | 16 | switch ($ordering) { |
| 15 | 17 | case \TournamentGenerator\Constants::POINTS:{ |
| 16 | 18 | uasort($teams, function($a, $b) use ($group) { |
| 17 | - if ($a->groupResults[$group->id]["points"] === $b->groupResults[$group->id]["points"] && $a->groupResults[$group->id]["score"] === $b->groupResults[$group->id]["score"]) return 0; |
|
| 18 | - if ($a->groupResults[$group->id]["points"] === $b->groupResults[$group->id]["points"]) return ($a->groupResults[$group->id]["score"] > $b->groupResults[$group->id]["score"] ? -1 : 1); |
|
| 19 | + if ($a->groupResults[$group->id]["points"] === $b->groupResults[$group->id]["points"] && $a->groupResults[$group->id]["score"] === $b->groupResults[$group->id]["score"]) { |
|
| 20 | + return 0; |
|
| 21 | + } |
|
| 22 | + if ($a->groupResults[$group->id]["points"] === $b->groupResults[$group->id]["points"]) { |
|
| 23 | + return ($a->groupResults[$group->id]["score"] > $b->groupResults[$group->id]["score"] ? -1 : 1); |
|
| 24 | + } |
|
| 19 | 25 | return ($a->groupResults[$group->id]["points"] > $b->groupResults[$group->id]["points"] ? -1 : 1); |
| 20 | 26 | }); |
| 21 | 27 | break;} |
| 22 | 28 | case \TournamentGenerator\Constants::SCORE:{ |
| 23 | 29 | uasort($teams, function($a, $b) use ($group) { |
| 24 | - if ($a->groupResults[$group->id]["score"] === $b->groupResults[$group->id]["score"]) return 0; |
|
| 30 | + if ($a->groupResults[$group->id]["score"] === $b->groupResults[$group->id]["score"]) { |
|
| 31 | + return 0; |
|
| 32 | + } |
|
| 25 | 33 | return ($a->groupResults[$group->id]["score"] > $b->groupResults[$group->id]["score"] ? -1 : 1); |
| 26 | 34 | }); |
| 27 | 35 | break;} |
@@ -30,21 +38,29 @@ discard block |
||
| 30 | 38 | return $teams; |
| 31 | 39 | } |
| 32 | 40 | public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) { |
| 33 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
| 41 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
| 42 | + throw new \Exception('Unknown ordering type `'.$ordering.'`'); |
|
| 43 | + } |
|
| 34 | 44 | |
| 35 | 45 | $groupsIds = $round->getGroupsIds(); |
| 36 | 46 | |
| 37 | 47 | switch ($ordering) { |
| 38 | 48 | case \TournamentGenerator\Constants::POINTS:{ |
| 39 | 49 | uasort($teams, function($a, $b) use ($groupsIds) { |
| 40 | - if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
|
| 41 | - if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
|
| 50 | + if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) { |
|
| 51 | + return 0; |
|
| 52 | + } |
|
| 53 | + if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) { |
|
| 54 | + return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
|
| 55 | + } |
|
| 42 | 56 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
| 43 | 57 | }); |
| 44 | 58 | break;} |
| 45 | 59 | case \TournamentGenerator\Constants::SCORE:{ |
| 46 | 60 | uasort($teams, function($a, $b) use ($groupsIds) { |
| 47 | - if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
|
| 61 | + if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) { |
|
| 62 | + return 0; |
|
| 63 | + } |
|
| 48 | 64 | return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
| 49 | 65 | }); |
| 50 | 66 | break;} |
@@ -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 | |
@@ -99,8 +99,11 @@ discard block |
||
| 99 | 99 | public function getTeams($filters = []) { |
| 100 | 100 | $teams = $this->teams; |
| 101 | 101 | |
| 102 | - if (gettype($filters) !== 'array' && $filters instanceof TeamFilter) $filters = [$filters]; |
|
| 103 | - elseif (gettype($filters) !== 'array') $filters = []; |
|
| 102 | + if (gettype($filters) !== 'array' && $filters instanceof TeamFilter) { |
|
| 103 | + $filters = [$filters]; |
|
| 104 | + } elseif (gettype($filters) !== 'array') { |
|
| 105 | + $filters = []; |
|
| 106 | + } |
|
| 104 | 107 | |
| 105 | 108 | // APPLY FILTERS |
| 106 | 109 | $filter = new Filter($this, $filters); |
@@ -125,7 +128,9 @@ discard block |
||
| 125 | 128 | return $t; |
| 126 | 129 | } |
| 127 | 130 | public function sortTeams($filters = [], $ordering = null) { |
| 128 | - if (!isset($ordering)) $ordering = $this->ordering; |
|
| 131 | + if (!isset($ordering)) { |
|
| 132 | + $ordering = $this->ordering; |
|
| 133 | + } |
|
| 129 | 134 | Utilis\Sorter\Teams::sortGroup($this->teams, $this, $ordering); |
| 130 | 135 | return $this->getTeams($filters); |
| 131 | 136 | } |
@@ -139,7 +144,9 @@ discard block |
||
| 139 | 144 | } |
| 140 | 145 | |
| 141 | 146 | public function setOrdering(string $ordering = \TournamentGenerator\Constants::POINTS) { |
| 142 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 147 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
| 148 | + throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 149 | + } |
|
| 143 | 150 | $this->ordering = $ordering; |
| 144 | 151 | return $this; |
| 145 | 152 | } |
@@ -171,8 +178,9 @@ discard block |
||
| 171 | 178 | } |
| 172 | 179 | public function addProgressed(...$teams) { |
| 173 | 180 | foreach ($teams as $team) { |
| 174 | - if ($team instanceOf Team) $this->progressed[] = $team->id; |
|
| 175 | - elseif (gettype($team) === 'array') { |
|
| 181 | + if ($team instanceOf Team) { |
|
| 182 | + $this->progressed[] = $team->id; |
|
| 183 | + } elseif (gettype($team) === 'array') { |
|
| 176 | 184 | $this->progressed = array_merge($this->progressed, array_filter($team, function($a) { |
| 177 | 185 | return ($a instanceof Team); |
| 178 | 186 | })); |
@@ -201,7 +209,9 @@ discard block |
||
| 201 | 209 | $this->games = array_merge($this->games, array_filter($game, function($a){ return ($a instanceof Game); })); |
| 202 | 210 | continue; |
| 203 | 211 | } |
| 204 | - if (!$game instanceof Game) throw new \Exception('Trying to add game which is not instance of Game object.'); |
|
| 212 | + if (!$game instanceof Game) { |
|
| 213 | + throw new \Exception('Trying to add game which is not instance of Game object.'); |
|
| 214 | + } |
|
| 205 | 215 | $this->games[] = $game; |
| 206 | 216 | } |
| 207 | 217 | return $this; |
@@ -210,7 +220,9 @@ discard block |
||
| 210 | 220 | return $this->games; |
| 211 | 221 | } |
| 212 | 222 | public function orderGames() { |
| 213 | - if (count($this->games) <= 4) return $this->games; |
|
| 223 | + if (count($this->games) <= 4) { |
|
| 224 | + return $this->games; |
|
| 225 | + } |
|
| 214 | 226 | $this->games = $this->generator->orderGames(); |
| 215 | 227 | return $this->games; |
| 216 | 228 | } |
@@ -226,7 +238,9 @@ discard block |
||
| 226 | 238 | } |
| 227 | 239 | public function isPlayed(){ |
| 228 | 240 | foreach ($this->games as $game) { |
| 229 | - if (!$game->isPlayed()) return false; |
|
| 241 | + if (!$game->isPlayed()) { |
|
| 242 | + return false; |
|
| 243 | + } |
|
| 230 | 244 | } |
| 231 | 245 | return true; |
| 232 | 246 | } |
@@ -50,7 +50,7 @@ |
||
| 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' => \TournamentGenerator\Constants::ROUND_TWO |
@@ -78,8 +78,11 @@ discard block |
||
| 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 |
||
| 94 | 97 | |
| 95 | 98 | public function addRound(Round ...$rounds) { |
| 96 | 99 | foreach ($rounds as $round) { |
| 97 | - if ($round instanceof Round) $this->rounds[] = $round; |
|
| 98 | - else throw new \Exception('Trying to add round which is not an instance of the Round class.'); |
|
| 100 | + if ($round instanceof Round) { |
|
| 101 | + $this->rounds[] = $round; |
|
| 102 | + } else { |
|
| 103 | + throw new \Exception('Trying to add round which is not an instance of the Round class.'); |
|
| 104 | + } |
|
| 99 | 105 | } |
| 100 | 106 | return $this; |
| 101 | 107 | } |
@@ -120,8 +126,7 @@ discard block |
||
| 120 | 126 | if ($team instanceof Team) { |
| 121 | 127 | $this->teams[] = $team; |
| 122 | 128 | continue; |
| 123 | - } |
|
| 124 | - elseif (gettype($team) === 'array') { |
|
| 129 | + } elseif (gettype($team) === 'array') { |
|
| 125 | 130 | $teams = array_merge($teams, array_filter($team, function($a) { |
| 126 | 131 | return ($a instanceof Team); |
| 127 | 132 | })); |
@@ -147,7 +152,9 @@ discard block |
||
| 147 | 152 | } |
| 148 | 153 | $this->teams = $teams; |
| 149 | 154 | } |
| 150 | - if ($ordered) $this->sortTeams($ordering); |
|
| 155 | + if ($ordered) { |
|
| 156 | + $this->sortTeams($ordering); |
|
| 157 | + } |
|
| 151 | 158 | return $this->teams; |
| 152 | 159 | } |
| 153 | 160 | public function sortTeams($ordering = \TournamentGenerator\Constants::POINTS) { |
@@ -170,7 +177,9 @@ discard block |
||
| 170 | 177 | |
| 171 | 178 | public function splitTeams(Round ...$wheres) { |
| 172 | 179 | |
| 173 | - if (count($wheres) === 0) $wheres = $this->getRounds(); |
|
| 180 | + if (count($wheres) === 0) { |
|
| 181 | + $wheres = $this->getRounds(); |
|
| 182 | + } |
|
| 174 | 183 | |
| 175 | 184 | foreach ($wheres as $key => $value) { |
| 176 | 185 | if (gettype($value) === 'array') { |
@@ -185,7 +194,9 @@ discard block |
||
| 185 | 194 | |
| 186 | 195 | while (count($teams) > 0) { |
| 187 | 196 | foreach ($wheres as $where) { |
| 188 | - if (count($teams) > 0) $where->addTeam(array_shift($teams)); |
|
| 197 | + if (count($teams) > 0) { |
|
| 198 | + $where->addTeam(array_shift($teams)); |
|
| 199 | + } |
|
| 189 | 200 | } |
| 190 | 201 | } |
| 191 | 202 | foreach ($wheres as $where) { |
@@ -197,13 +208,17 @@ discard block |
||
| 197 | 208 | public function genGamesSimulate(bool $returnTime = false) { |
| 198 | 209 | $games = Utilis\Simulator::simulateTournament($this); |
| 199 | 210 | |
| 200 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 211 | + if ($returnTime) { |
|
| 212 | + return $this->getTournamentTime(); |
|
| 213 | + } |
|
| 201 | 214 | return $games; |
| 202 | 215 | } |
| 203 | 216 | public function genGamesSimulateReal(bool $returnTime = false) { |
| 204 | 217 | $games = Utilis\Simulator::simulateTournamentReal($this); |
| 205 | 218 | |
| 206 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 219 | + if ($returnTime) { |
|
| 220 | + return $this->getTournamentTime(); |
|
| 221 | + } |
|
| 207 | 222 | return $games; |
| 208 | 223 | } |
| 209 | 224 | |