@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | return $this->name; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function addGroup(Group ...$groups){ |
|
| 26 | + public function addGroup(Group ...$groups) { |
|
| 27 | 27 | foreach ($groups as $group) { |
| 28 | 28 | if ($group instanceof Group) $this->groups[] = $group; |
| 29 | 29 | else throw new \Exception('Trying to add group which is not an instance of Group class.'); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->groups[] = $g->setSkip($this->allowSkip); |
| 36 | 36 | return $g; |
| 37 | 37 | } |
| 38 | - public function getGroups(){ |
|
| 38 | + public function getGroups() { |
|
| 39 | 39 | $this->orderGroups(); |
| 40 | 40 | return $this->groups; |
| 41 | 41 | } |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | return array_map(function($a) { return $a->id; }, $this->groups); |
| 45 | 45 | } |
| 46 | 46 | public function orderGroups() { |
| 47 | - usort($this->groups, function($a, $b){ |
|
| 48 | - return $a->order - $b->order; |
|
| 47 | + usort($this->groups, function($a, $b) { |
|
| 48 | + return $a->order-$b->order; |
|
| 49 | 49 | }); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function allowSkip(){ |
|
| 52 | + public function allowSkip() { |
|
| 53 | 53 | $this->allowSkip = true; |
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | - public function disallowSkip(){ |
|
| 56 | + public function disallowSkip() { |
|
| 57 | 57 | $this->allowSkip = false; |
| 58 | 58 | return $this; |
| 59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | return $this->allowSkip; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function genGames(){ |
|
| 68 | + public function genGames() { |
|
| 69 | 69 | foreach ($this->groups as $group) { |
| 70 | 70 | $group->genGames(); |
| 71 | 71 | $this->games = array_merge($this->games, $group->orderGames()); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function getGames() { |
| 76 | 76 | return $this->games; |
| 77 | 77 | } |
| 78 | - public function isPlayed(){ |
|
| 78 | + public function isPlayed() { |
|
| 79 | 79 | foreach ($this->groups as $group) { |
| 80 | 80 | if (!$group->isPlayed()) return false; |
| 81 | 81 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function addTeam(...$teams) { |
| 86 | 86 | foreach ($teams as $team) { |
| 87 | - if ($team instanceof Team) { |
|
| 87 | + if ($team instanceof Team) { |
|
| 88 | 88 | $this->teams[] = $team; |
| 89 | 89 | } |
| 90 | 90 | elseif (gettype($team) === 'array') { |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
| 134 | 134 | return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1); |
| 135 | 135 | }); |
| 136 | - break;} |
|
| 136 | + break; } |
|
| 137 | 137 | case SCORE:{ |
| 138 | 138 | uasort($this->teams, function($a, $b) use ($groupsIds) { |
| 139 | 139 | if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0; |
| 140 | 140 | return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1); |
| 141 | 141 | }); |
| 142 | - break;} |
|
| 142 | + break; } |
|
| 143 | 143 | } |
| 144 | 144 | return $this->teams; |
| 145 | 145 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | return $this; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function progress(bool $blank = false){ |
|
| 171 | + public function progress(bool $blank = false) { |
|
| 172 | 172 | foreach ($this->groups as $group) { |
| 173 | 173 | $group->progress($blank); |
| 174 | 174 | } |
@@ -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\TWO_TWO |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | $this->group = $group; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function allowSkip(){ |
|
| 22 | + public function allowSkip() { |
|
| 23 | 23 | $this->allowSkip = true; |
| 24 | 24 | return $this; |
| 25 | 25 | } |
| 26 | - public function disallowSkip(){ |
|
| 26 | + public function disallowSkip() { |
|
| 27 | 27 | $this->allowSkip = false; |
| 28 | 28 | return $this; |
| 29 | 29 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function setInGame(int $inGame) { |
| 49 | - if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
| 49 | + if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given'); |
|
| 50 | 50 | $this->inGame = $inGame; |
| 51 | 51 | return $this; |
| 52 | 52 | } |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | switch ($this->type) { |
| 68 | 68 | case \TournamentGenerator\R_R:{ |
| 69 | 69 | $this->group->addGame($this->r_rGames()); |
| 70 | - break;} |
|
| 70 | + break; } |
|
| 71 | 71 | case \TournamentGenerator\TWO_TWO: |
| 72 | 72 | $teams = $this->group->getTeams(); |
| 73 | 73 | $discard = []; |
| 74 | 74 | shuffle($teams); |
| 75 | 75 | $count = count($teams); |
| 76 | - while (count($teams) % $this->inGame !== 0) { $discard[] = array_shift($teams); } |
|
| 76 | + while (count($teams)%$this->inGame !== 0) { $discard[] = array_shift($teams); } |
|
| 77 | 77 | |
| 78 | 78 | while (count($teams) > 0) { |
| 79 | 79 | $tInGame = []; |
| 80 | - for ($i=0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); } |
|
| 80 | + for ($i = 0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); } |
|
| 81 | 81 | $this->group->game($tInGame); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | $games = array_merge($games, $gamesTemp); |
| 125 | 125 | } |
| 126 | - break;} |
|
| 126 | + break; } |
|
| 127 | 127 | case 4:{ |
| 128 | 128 | $teamsB = $teams; |
| 129 | 129 | $lockedTeam1 = array_shift($teamsB); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $lockedTeam1 = array_shift($teamsB); |
| 141 | 141 | } |
| 142 | 142 | $games[] = new \TournamentGenerator\Game(array_merge([$lockedTeam1], $teamsB), $this->group); |
| 143 | - break;} |
|
| 143 | + break; } |
|
| 144 | 144 | } |
| 145 | 145 | return $games; |
| 146 | 146 | } |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | public static function circle_genGames2(array $teams = [], Group $group) { |
| 156 | 156 | $bracket = []; // ARRAY OF GAMES |
| 157 | 157 | |
| 158 | - if (count($teams) % 2 != 0) $teams[] = \TournamentGenerator\DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
| 158 | + if (count($teams)%2 != 0) $teams[] = \TournamentGenerator\DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY |
|
| 159 | 159 | |
| 160 | 160 | shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS |
| 161 | 161 | |
| 162 | - for ($i=0; $i < count($teams)-1; $i++) { |
|
| 162 | + for ($i = 0; $i < count($teams)-1; $i++) { |
|
| 163 | 163 | $bracket = array_merge($bracket, Generator::circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND |
| 164 | 164 | |
| 165 | 165 | $teams = Generator::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $bracket = []; |
| 175 | 175 | |
| 176 | - for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
| 176 | + for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS |
|
| 177 | 177 | |
| 178 | 178 | $home = $teams[$i]; |
| 179 | 179 | $reverse = array_reverse($teams); |
@@ -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; |