@@ -155,7 +155,7 @@ |
||
| 155 | 155 | */ |
| 156 | 156 | public function getTournamentTime() : int { |
| 157 | 157 | $games = count($this->getGames()); |
| 158 | - return $games * $this->expectedPlay + ($games - 1) * $this->expectedGameWait + (count($this->getRounds()) - 1) * $this->expectedRoundWait + (count($this->getCategories()) - 1) * $this->expectedCategoryWait; |
|
| 158 | + return $games*$this->expectedPlay+($games-1)*$this->expectedGameWait+(count($this->getRounds())-1)*$this->expectedRoundWait+(count($this->getCategories())-1)*$this->expectedCategoryWait; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | foreach ($groupsId as $id) { |
| 122 | 122 | $games += count($team->getGames(null, $id)); |
| 123 | 123 | } |
| 124 | - return self::calcSum($team, $groupsId) / $games; |
|
| 124 | + return self::calcSum($team, $groupsId)/$games; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | public function setType(string $type = Constants::ROUND_ROBIN) : Generator { |
| 63 | 63 | if (in_array($type, Constants::GroupTypes, true)) { |
| 64 | 64 | $this->type = $type; |
| 65 | - } |
|
| 66 | - else { |
|
| 65 | + } else { |
|
| 67 | 66 | throw new Exception('Unknown group type: '.$type); |
| 68 | 67 | } |
| 69 | 68 | return $this; |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public static function circle_genGames2(Group $group, array $teams = []) : array { |
| 180 | 180 | |
| 181 | - if (count($teams) % 2 !== 0) { |
|
| 181 | + if (count($teams)%2 !== 0) { |
|
| 182 | 182 | $teams[] = Constants::DUMMY_TEAM; |
| 183 | 183 | } // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
| 184 | 184 | |
| 185 | 185 | shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS |
| 186 | 186 | |
| 187 | 187 | $rounds = []; |
| 188 | - for ($i = 0; $i < count($teams) - 1; $i++) { |
|
| 188 | + for ($i = 0; $i < count($teams)-1; $i++) { |
|
| 189 | 189 | $rounds[] = self::circle_saveBracket($teams, $group); // SAVE CURRENT ROUND |
| 190 | 190 | |
| 191 | 191 | $teams = self::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $bracket = []; |
| 209 | 209 | |
| 210 | - for ($i = 0; $i < count($teams) / 2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
| 210 | + for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
| 211 | 211 | |
| 212 | 212 | $home = $teams[$i]; |
| 213 | 213 | $reverse = array_reverse($teams); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | public static function circle_rotateBracket(array $teams) : array { |
| 236 | 236 | |
| 237 | 237 | $first = array_shift($teams); // THE FIRST TEAM REMAINS FIRST |
| 238 | - $last = array_shift($teams); // THE SECOND TEAM MOVES TO LAST PLACE |
|
| 238 | + $last = array_shift($teams); // THE SECOND TEAM MOVES TO LAST PLACE |
|
| 239 | 239 | |
| 240 | 240 | return array_merge([$first], $teams, [$last]); // MERGE BACK TOGETHER |
| 241 | 241 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | shuffle($teams); |
| 305 | 305 | $count = count($teams); // Store original count for exception |
| 306 | 306 | |
| 307 | - $discard = array_splice($teams, 0, $count % $this->inGame); |
|
| 307 | + $discard = array_splice($teams, 0, $count%$this->inGame); |
|
| 308 | 308 | |
| 309 | 309 | $teams = $this->saveTwoTwoGames($teams); |
| 310 | 310 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $games = []; |
| 334 | 334 | |
| 335 | 335 | // Split teams into chunks of maximum size |
| 336 | - $groups = array_chunk($teams, (int) ceil($count / ceil($count / $this->maxSize))); |
|
| 336 | + $groups = array_chunk($teams, (int) ceil($count/ceil($count/$this->maxSize))); |
|
| 337 | 337 | // Generate games for each chunk |
| 338 | 338 | foreach ($groups as $group) { |
| 339 | 339 | $games[] = $this->r_rGames($group); |
@@ -221,13 +221,11 @@ |
||
| 221 | 221 | $this->drawIds[] = $team->getId(); |
| 222 | 222 | $team->addDraw($this->group->getId()); |
| 223 | 223 | $this->results[$team->getId()] += ['points' => $this->group->getDrawPoints(), 'type' => 'draw']; |
| 224 | - } |
|
| 225 | - elseif ($teamPosition === 1) { |
|
| 224 | + } elseif ($teamPosition === 1) { |
|
| 226 | 225 | $this->winId = $team->getId(); |
| 227 | 226 | $team->addWin($this->group->getId()); |
| 228 | 227 | $this->results[$team->getId()] += ['points' => $this->group->getWinPoints(), 'type' => 'win']; |
| 229 | - } |
|
| 230 | - else { |
|
| 228 | + } else { |
|
| 231 | 229 | $this->lossId = $team->getId(); |
| 232 | 230 | $team->addLoss($this->group->getId()); |
| 233 | 231 | $this->results[$team->getId()] += ['points' => $this->group->getLostPoints(), 'type' => 'loss']; |
@@ -202,7 +202,7 @@ |
||
| 202 | 202 | public function getTeam($id) : ?Team { |
| 203 | 203 | $key = array_search($id, array_map(static function($a) { |
| 204 | 204 | return $a->getId(); |
| 205 | - }, $this->teams), true); |
|
| 205 | + }, $this->teams), true); |
|
| 206 | 206 | return ($key !== false ? $this->teams[$key] : null); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -50,14 +50,14 @@ |
||
| 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('TOP')->setType(Constants::ROUND_TWO); |
| 55 | 55 | |
| 56 | 56 | $filter_win_2 = new TeamFilter('wins', '=', 2, [$group_0_0, $group_top]); |
| 57 | 57 | $filter_loss_2 = new TeamFilter('losses', '=', 2, [$group_0_0, $group_top]); |
| 58 | 58 | $filter_win_1_both = new TeamFilter('wins', '=', 1, [$group_0_0, $group_top]); |
| 59 | 59 | $filter_loss_1_both = new TeamFilter('losses', '=', 1, [$group_0_0, $group_top]); |
| 60 | - $group_0_0->progression($group_top, 0, 1)->addFilter($filter_win_1); // PROGRESS THE BEST WINNING TEAM |
|
| 60 | + $group_0_0->progression($group_top, 0, 1)->addFilter($filter_win_1); // PROGRESS THE BEST WINNING TEAM |
|
| 61 | 61 | $group_0_0->progression($group_top, 0, 1)->addFilter($filter_loss_1); // PROGRESS THE BEST LOSING TEAM |
| 62 | 62 | $group_top->progression($group_2_0)->addFilter($filter_win_2); |
| 63 | 63 | $group_top->progression($group_0_2)->addFilter($filter_loss_2); |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | $byes = 0; |
| 34 | 34 | if (!Functions::isPowerOf2($countTeams)) { |
| 35 | 35 | $nextPow = Functions::nextPowerOf2($countTeams); |
| 36 | - $byes = $nextPow - $countTeams; |
|
| 36 | + $byes = $nextPow-$countTeams; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $roundsNum = log($countTeams + $byes, 2); // NUMBER OF ROUNDS |
|
| 39 | + $roundsNum = log($countTeams+$byes, 2); // NUMBER OF ROUNDS |
|
| 40 | 40 | |
| 41 | 41 | $startRound = $this->round('Start'); |
| 42 | 42 | |
| 43 | 43 | $previousGroups = []; |
| 44 | 44 | |
| 45 | - for ($i = 1; $i <= (($countTeams + $byes) / 2); $i++) { |
|
| 45 | + for ($i = 1; $i <= (($countTeams+$byes)/2); $i++) { |
|
| 46 | 46 | $g = $startRound->group('Round 1 '.$i)->setInGame(2)->setType(Constants::ROUND_TWO); |
| 47 | 47 | $previousGroups[] = $g; |
| 48 | 48 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | for ($r = 2; $r <= $roundsNum; $r++) { |
| 53 | 53 | $groups = []; |
| 54 | 54 | $round = $this->round('Round '.$r); |
| 55 | - for ($g = 1; $g <= (($countTeams + $byes) / (2 ** $r)); $g++) { |
|
| 55 | + for ($g = 1; $g <= (($countTeams+$byes)/(2 ** $r)); $g++) { |
|
| 56 | 56 | $group = $round->group('Round '.$r.' - '.$g)->setInGame(2)->setType(Constants::ROUND_TWO); |
| 57 | 57 | $groups[] = $group; |
| 58 | 58 | array_shift($previousGroups)->progression($group, 0, 1); // PROGRESS FROM GROUP BEFORE |
@@ -95,15 +95,13 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | if ($blank) { |
| 97 | 97 | $teams = $this->from->isPlayed() ? $this->from->sortTeams(null, $this->filters) : $this->from->simulate($this->filters); |
| 98 | - } |
|
| 99 | - else { |
|
| 98 | + } else { |
|
| 100 | 99 | $teams = $this->from->sortTeams(null, $this->filters); |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | if ($this->start !== 0 || $this->len !== null) { |
| 104 | 103 | $next = array_splice($teams, $this->start, ($this->len ?? count($teams))); |
| 105 | - } |
|
| 106 | - else { |
|
| 104 | + } else { |
|
| 107 | 105 | $next = $teams; |
| 108 | 106 | } |
| 109 | 107 | |
@@ -112,8 +110,7 @@ discard block |
||
| 112 | 110 | foreach ($next as $team) { |
| 113 | 111 | if ($blank) { |
| 114 | 112 | $this->to->addTeam(new BlankTeam($this.' - '.$i++, $team, $this->from, $this)); |
| 115 | - } |
|
| 116 | - else { |
|
| 113 | + } else { |
|
| 117 | 114 | $team->addPoints($this->from->getProgressPoints()); |
| 118 | 115 | } |
| 119 | 116 | } |
@@ -112,8 +112,7 @@ discard block |
||
| 112 | 112 | $data['categories'] = [ |
| 113 | 113 | $this->object->getId() => $this->getCategoryData($this->object), |
| 114 | 114 | ]; |
| 115 | - } |
|
| 116 | - elseif ($this->object instanceof WithCategories) { |
|
| 115 | + } elseif ($this->object instanceof WithCategories) { |
|
| 117 | 116 | $data['categories'] = []; |
| 118 | 117 | foreach ($this->object->getCategories() as $category) { |
| 119 | 118 | $data['categories'][$category->getId()] = $this->getCategoryData($category); |
@@ -153,8 +152,7 @@ discard block |
||
| 153 | 152 | $data['rounds'] = [ |
| 154 | 153 | $this->object->getId() => $this->getRoundData($this->object), |
| 155 | 154 | ]; |
| 156 | - } |
|
| 157 | - elseif ($this->object instanceof WithRounds) { |
|
| 155 | + } elseif ($this->object instanceof WithRounds) { |
|
| 158 | 156 | $data['rounds'] = []; |
| 159 | 157 | foreach ($this->object->getRounds() as $round) { |
| 160 | 158 | $data['rounds'][$round->getId()] = $this->getRoundData($round); |
@@ -197,8 +195,7 @@ discard block |
||
| 197 | 195 | foreach ($this->object->getProgressions() as $progression) { |
| 198 | 196 | $data['progressions'][] = $this->getProgressionData($progression); |
| 199 | 197 | } |
| 200 | - } |
|
| 201 | - elseif ($this->object instanceof WithGroups) { |
|
| 198 | + } elseif ($this->object instanceof WithGroups) { |
|
| 202 | 199 | foreach ($this->object->getGroups() as $group) { |
| 203 | 200 | $data['groups'][$group->getId()] = $this->getGroupData($group); |
| 204 | 201 | foreach ($group->getProgressions() as $progression) { |
@@ -564,7 +564,7 @@ |
||
| 564 | 564 | * @return bool |
| 565 | 565 | */ |
| 566 | 566 | public static function isObject($data) : bool { |
| 567 | - return is_object($data) || (is_array($data) && !empty($data) && array_keys($data) !== range(0, count($data) - 1)); |
|
| 567 | + return is_object($data) || (is_array($data) && !empty($data) && array_keys($data) !== range(0, count($data)-1)); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -490,8 +490,7 @@ |
||
| 490 | 490 | foreach (((array) $data) as $key => $value) { |
| 491 | 491 | self::validateParams($value, array_merge($keys, [$key]), $setting['parameters'][$key]); |
| 492 | 492 | } |
| 493 | - } |
|
| 494 | - else { |
|
| 493 | + } else { |
|
| 495 | 494 | foreach (((array) $data) as $object) { |
| 496 | 495 | foreach (((array) $object) as $key => $value) { |
| 497 | 496 | self::validateParams($value, array_merge($keys, [$key]), $setting['parameters'][$key]); |