@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | return 'Group '.$this->name; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function allowSkip(){ |
|
| 57 | + public function allowSkip() { |
|
| 58 | 58 | $this->generator->allowSkip(); |
| 59 | 59 | return $this; |
| 60 | 60 | } |
| 61 | - public function disallowSkip(){ |
|
| 61 | + public function disallowSkip() { |
|
| 62 | 62 | $this->generator->disallowSkip(); |
| 63 | 63 | return $this; |
| 64 | 64 | } |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | $this->games[] = $g; |
| 195 | 195 | return $g; |
| 196 | 196 | } |
| 197 | - public function addGame(...$games){ |
|
| 197 | + public function addGame(...$games) { |
|
| 198 | 198 | foreach ($games as $key => $game) { |
| 199 | 199 | if (gettype($game) === 'array') { |
| 200 | 200 | unset($games[$key]); |
| 201 | - $games = array_merge($games, array_filter($game, function($a){ return ($a instanceof Game); })); |
|
| 201 | + $games = array_merge($games, array_filter($game, function($a) { return ($a instanceof Game); })); |
|
| 202 | 202 | continue; |
| 203 | 203 | } |
| 204 | 204 | if (!$game instanceof Game) throw new \Exception('Trying to add game which is not instance of Game object.'); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | return $this; |
| 226 | 226 | } |
| 227 | - public function isPlayed(){ |
|
| 227 | + public function isPlayed() { |
|
| 228 | 228 | foreach ($this->games as $game) { |
| 229 | 229 | if (!$game->isPlayed()) return false; |
| 230 | 230 | } |
@@ -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 = \POINTS) { |
| 142 | - if (!in_array($ordering, orderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 147 | + if (!in_array($ordering, 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 | $games = array_merge($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 | } |
@@ -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 = \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 | |