@@ -12,12 +12,12 @@ |
||
| 12 | 12 | private $filters = []; |
| 13 | 13 | |
| 14 | 14 | function __construct(array $groups, array $filters) { |
| 15 | - $this->groups = array_filter($groups, function($a) {return $a instanceof Group;}); |
|
| 15 | + $this->groups = array_filter($groups, function($a) {return $a instanceof Group; }); |
|
| 16 | 16 | $this->filters = $filters; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | private function getGroupsIds() { |
| 20 | - return array_map(function($a){return $a->getId();}, $this->groups); |
|
| 20 | + return array_map(function($a) {return $a->getId(); }, $this->groups); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -29,8 +29,7 @@ discard block |
||
| 29 | 29 | if (gettype($filter) === 'array') { |
| 30 | 30 | $this->filterMulti($teams, $filter, $key); |
| 31 | 31 | continue; |
| 32 | - } |
|
| 33 | - elseif ($filter instanceof TeamFilter) { |
|
| 32 | + } elseif ($filter instanceof TeamFilter) { |
|
| 34 | 33 | $teams = array_filter($teams, function($team) use ($filter) {return $filter->validate($team, $this->getGroupsIds(), 'sum', $this->groups[0]); }); |
| 35 | 34 | continue; |
| 36 | 35 | } |
@@ -43,12 +42,18 @@ discard block |
||
| 43 | 42 | switch (strtolower($how)) { |
| 44 | 43 | case 'and': |
| 45 | 44 | foreach ($teams as $tkey => $team) { |
| 46 | - if (!$this->filterAnd($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY |
|
| 45 | + if (!$this->filterAnd($team, $filters)) { |
|
| 46 | + unset($teams[$tkey]); |
|
| 47 | + } |
|
| 48 | + // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY |
|
| 47 | 49 | } |
| 48 | 50 | return true; |
| 49 | 51 | case 'or': |
| 50 | 52 | foreach ($teams as $tkey => $team) { |
| 51 | - if (!$this->filterOr($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY |
|
| 53 | + if (!$this->filterOr($team, $filters)) { |
|
| 54 | + unset($teams[$tkey]); |
|
| 55 | + } |
|
| 56 | + // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY |
|
| 52 | 57 | } |
| 53 | 58 | return true; |
| 54 | 59 | } |
@@ -58,21 +63,28 @@ discard block |
||
| 58 | 63 | private function filterAnd(Team $team, array $filters) { |
| 59 | 64 | foreach ($filters as $key => $value) { |
| 60 | 65 | if (is_array($value)) { |
| 61 | - if (is_int($key)) $key = 'and'; |
|
| 66 | + if (is_int($key)) { |
|
| 67 | + $key = 'and'; |
|
| 68 | + } |
|
| 62 | 69 | switch (strtolower($key)) { |
| 63 | 70 | case 'and': |
| 64 | - if (!$this->filterAnd($team, $value)) return false; |
|
| 71 | + if (!$this->filterAnd($team, $value)) { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 65 | 74 | break; |
| 66 | 75 | case 'or': |
| 67 | - if (!$this->filterOr($team, $value)) return false; |
|
| 76 | + if (!$this->filterOr($team, $value)) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 68 | 79 | break; |
| 69 | 80 | default: |
| 70 | 81 | throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".'); |
| 71 | 82 | } |
| 72 | 83 | continue; |
| 73 | - } |
|
| 74 | - elseif ($value instanceof TeamFilter) { |
|
| 75 | - if (!$value->validate($team, $this->getGroupsIds(), 'sum', $this->groups[0])) return false; |
|
| 84 | + } elseif ($value instanceof TeamFilter) { |
|
| 85 | + if (!$value->validate($team, $this->getGroupsIds(), 'sum', $this->groups[0])) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 76 | 88 | continue; |
| 77 | 89 | } |
| 78 | 90 | throw new \Exception('Filter ['.$key.'] is not an instance of TeamFilter class'); |
@@ -81,22 +93,29 @@ discard block |
||
| 81 | 93 | } |
| 82 | 94 | private function filterOr(Team $team, array $filters) { |
| 83 | 95 | foreach ($filters as $key => $value) { |
| 84 | - if (is_int($key)) $key = 'and'; |
|
| 96 | + if (is_int($key)) { |
|
| 97 | + $key = 'and'; |
|
| 98 | + } |
|
| 85 | 99 | if (is_array($value)) { |
| 86 | 100 | switch (strtolower($key)) { |
| 87 | 101 | case 'and': |
| 88 | - if ($this->filterAnd($team, $value)) return true; |
|
| 102 | + if ($this->filterAnd($team, $value)) { |
|
| 103 | + return true; |
|
| 104 | + } |
|
| 89 | 105 | break; |
| 90 | 106 | case 'or': |
| 91 | - if ($this->filterOr($team, $value)) return true; |
|
| 107 | + if ($this->filterOr($team, $value)) { |
|
| 108 | + return true; |
|
| 109 | + } |
|
| 92 | 110 | break; |
| 93 | 111 | default: |
| 94 | 112 | throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".'); |
| 95 | 113 | } |
| 96 | 114 | continue; |
| 97 | - } |
|
| 98 | - elseif ($value instanceof TeamFilter) { |
|
| 99 | - if ($value->validate($team, $this->getGroupsIds(), 'sum', $this->groups[0])) return true; |
|
| 115 | + } elseif ($value instanceof TeamFilter) { |
|
| 116 | + if ($value->validate($team, $this->getGroupsIds(), 'sum', $this->groups[0])) { |
|
| 117 | + return true; |
|
| 118 | + } |
|
| 100 | 119 | continue; |
| 101 | 120 | } |
| 102 | 121 | throw new \Exception('Filter ['.$key.'] is not an instance of TeamFilter class'); |
@@ -150,7 +150,9 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | $teams = \array_unique($teams); |
| 152 | 152 | $this->teams = $teams; |
| 153 | - if ($ordered) $teams = $this->sortTeams($ordering); |
|
| 153 | + if ($ordered) { |
|
| 154 | + $teams = $this->sortTeams($ordering); |
|
| 155 | + } |
|
| 154 | 156 | |
| 155 | 157 | // APPLY FILTERS |
| 156 | 158 | $filter = new Filter($this->getGroups(), $filters); |
@@ -183,14 +185,18 @@ discard block |
||
| 183 | 185 | |
| 184 | 186 | public function splitTeams(Round ...$wheres) { |
| 185 | 187 | |
| 186 | - if (count($wheres) === 0) $wheres = $this->getRounds(); |
|
| 188 | + if (count($wheres) === 0) { |
|
| 189 | + $wheres = $this->getRounds(); |
|
| 190 | + } |
|
| 187 | 191 | |
| 188 | 192 | $teams = $this->getTeams(); |
| 189 | 193 | shuffle($teams); |
| 190 | 194 | |
| 191 | 195 | while (count($teams) > 0) { |
| 192 | 196 | foreach ($wheres as $where) { |
| 193 | - if (count($teams) > 0) $where->addTeam(array_shift($teams)); |
|
| 197 | + if (count($teams) > 0) { |
|
| 198 | + $where->addTeam(array_shift($teams)); |
|
| 199 | + } |
|
| 194 | 200 | } |
| 195 | 201 | } |
| 196 | 202 | foreach ($wheres as $where) { |
@@ -202,13 +208,17 @@ discard block |
||
| 202 | 208 | public function genGamesSimulate(bool $returnTime = false) { |
| 203 | 209 | $games = Utilis\Simulator::simulateTournament($this); |
| 204 | 210 | |
| 205 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 211 | + if ($returnTime) { |
|
| 212 | + return $this->getTournamentTime(); |
|
| 213 | + } |
|
| 206 | 214 | return $games; |
| 207 | 215 | } |
| 208 | 216 | public function genGamesSimulateReal(bool $returnTime = false) { |
| 209 | 217 | $games = Utilis\Simulator::simulateTournamentReal($this); |
| 210 | 218 | |
| 211 | - if ($returnTime) return $this->getTournamentTime(); |
|
| 219 | + if ($returnTime) { |
|
| 220 | + return $this->getTournamentTime(); |
|
| 221 | + } |
|
| 212 | 222 | return $games; |
| 213 | 223 | } |
| 214 | 224 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | private $allowSkip = false; |
| 22 | 22 | |
| 23 | - function __construct(string $name = ''){ |
|
| 23 | + function __construct(string $name = '') { |
|
| 24 | 24 | $this->name = $name; |
| 25 | 25 | } |
| 26 | 26 | public function __toString() { |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | public function getCategoryWait() { |
| 64 | 64 | return $this->expectedCategoryWait; |
| 65 | 65 | } |
| 66 | - public function getTournamentTime(){ |
|
| 66 | + public function getTournamentTime() { |
|
| 67 | 67 | $games = count($this->getGames()); |
| 68 | 68 | return $games*$this->expectedPlay+($games-1)*$this->expectedGameWait+(count($this->getRounds())-1)*$this->expectedRoundWait+(count($this->getCategories())-1)*$this->expectedCategoryWait; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function allowSkip(){ |
|
| 71 | + public function allowSkip() { |
|
| 72 | 72 | $this->allowSkip = true; |
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | - public function disallowSkip(){ |
|
| 75 | + public function disallowSkip() { |
|
| 76 | 76 | $this->allowSkip = false; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return $this->allowSkip; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function addCategory(Category ...$categories){ |
|
| 87 | + public function addCategory(Category ...$categories) { |
|
| 88 | 88 | foreach ($categories as $category) { |
| 89 | 89 | $this->categories[] = $category; |
| 90 | 90 | } |
@@ -18,7 +18,9 @@ discard block |
||
| 18 | 18 | $game->setResults($results); |
| 19 | 19 | } |
| 20 | 20 | $return = $group->sortTeams(null, $filters); |
| 21 | - if (!$reset) return $return; |
|
| 21 | + if (!$reset) { |
|
| 22 | + return $return; |
|
| 23 | + } |
|
| 22 | 24 | foreach ($group->getGames() as $game) { |
| 23 | 25 | $game->resetResults(); |
| 24 | 26 | } |
@@ -27,14 +29,18 @@ discard block |
||
| 27 | 29 | |
| 28 | 30 | public static function simulateRound(\TournamentGenerator\Round $round) { |
| 29 | 31 | foreach ($round->getGroups() as $group) { |
| 30 | - if ($group->isPlayed()) continue; |
|
| 32 | + if ($group->isPlayed()) { |
|
| 33 | + continue; |
|
| 34 | + } |
|
| 31 | 35 | $group->simulate([], false); |
| 32 | 36 | } |
| 33 | 37 | return true; |
| 34 | 38 | } |
| 35 | 39 | |
| 36 | 40 | public static function simulateTournament(\TournamentGenerator\Tournament $tournament) { |
| 37 | - if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
| 41 | + if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) { |
|
| 42 | + throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
| 43 | + } |
|
| 38 | 44 | |
| 39 | 45 | $games = []; |
| 40 | 46 | |
@@ -51,7 +57,9 @@ discard block |
||
| 51 | 57 | |
| 52 | 58 | public static function simulateTournamentReal(\TournamentGenerator\Tournament $tournament) { |
| 53 | 59 | $games = []; |
| 54 | - if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
| 60 | + if (count($tournament->getCategories()) === 0 && count($tournament->getRounds()) === 0) { |
|
| 61 | + throw new \Exception('There are no rounds or categories to simulate games from.'); |
|
| 62 | + } |
|
| 55 | 63 | |
| 56 | 64 | foreach ($tournament->getRounds() as $round) { |
| 57 | 65 | $games = array_merge($games, $round->genGames()); |
@@ -62,7 +70,9 @@ discard block |
||
| 62 | 70 | } |
| 63 | 71 | |
| 64 | 72 | public static function simulateCategory(\TournamentGenerator\Category $category) { |
| 65 | - if (count($category->getRounds()) === 0) throw new \Exception('There are no rounds to simulate games from.'); |
|
| 73 | + if (count($category->getRounds()) === 0) { |
|
| 74 | + throw new \Exception('There are no rounds to simulate games from.'); |
|
| 75 | + } |
|
| 66 | 76 | |
| 67 | 77 | $games = []; |
| 68 | 78 | |
@@ -79,7 +89,9 @@ discard block |
||
| 79 | 89 | |
| 80 | 90 | public static function simulateCategoryReal(\TournamentGenerator\Category $category) { |
| 81 | 91 | $games = []; |
| 82 | - if (count($category->getRounds()) === 0) throw new \Exception('There are no rounds to simulate games from.'); |
|
| 92 | + if (count($category->getRounds()) === 0) { |
|
| 93 | + throw new \Exception('There are no rounds to simulate games from.'); |
|
| 94 | + } |
|
| 83 | 95 | |
| 84 | 96 | foreach ($category->getRounds() as $round) { |
| 85 | 97 | $games = array_merge($games, $round->genGames()); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $this->setId(isset($id) ? $id : uniqid()); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function addRound(Round ...$rounds){ |
|
| 20 | + public function addRound(Round ...$rounds) { |
|
| 21 | 21 | foreach ($rounds as $round) { |
| 22 | 22 | $this->rounds[] = $round; |
| 23 | 23 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $this->rounds[] = $r->setSkip($this->allowSkip); |
| 29 | 29 | return $r; |
| 30 | 30 | } |
| 31 | - public function getRounds(){ |
|
| 31 | + public function getRounds() { |
|
| 32 | 32 | return $this->rounds; |
| 33 | 33 | } |
| 34 | 34 | public function getGroups() { |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | return $groups; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function allowSkip(){ |
|
| 42 | + public function allowSkip() { |
|
| 43 | 43 | $this->allowSkip = true; |
| 44 | 44 | return $this; |
| 45 | 45 | } |
| 46 | - public function disallowSkip(){ |
|
| 46 | + public function disallowSkip() { |
|
| 47 | 47 | $this->allowSkip = false; |
| 48 | 48 | return $this; |
| 49 | 49 | } |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | $teams = \array_unique($teams); |
| 75 | 75 | $this->teams = $teams; |
| 76 | - if ($ordered) $teams = $this->sortTeams($ordering); |
|
| 76 | + if ($ordered) { |
|
| 77 | + $teams = $this->sortTeams($ordering); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | // APPLY FILTERS |
| 79 | 81 | $filter = new Filter($this->getGroups(), $filters); |
@@ -106,14 +108,18 @@ discard block |
||
| 106 | 108 | |
| 107 | 109 | public function splitTeams(Round ...$wheres) { |
| 108 | 110 | |
| 109 | - if (count($wheres) === 0) $wheres = $this->getRounds(); |
|
| 111 | + if (count($wheres) === 0) { |
|
| 112 | + $wheres = $this->getRounds(); |
|
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | $teams = $this->getTeams(); |
| 112 | 116 | shuffle($teams); |
| 113 | 117 | |
| 114 | 118 | while (count($teams) > 0) { |
| 115 | 119 | foreach ($wheres as $where) { |
| 116 | - if (count($teams) > 0) $where->addTeam(array_shift($teams)); |
|
| 120 | + if (count($teams) > 0) { |
|
| 121 | + $where->addTeam(array_shift($teams)); |
|
| 122 | + } |
|
| 117 | 123 | } |
| 118 | 124 | } |
| 119 | 125 | foreach ($wheres as $where) { |
@@ -14,20 +14,20 @@ |
||
| 14 | 14 | private $sumScore = 0; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * ARRAY WITH GROUPS AND IT'S RESULTS |
|
| 18 | - * array ( |
|
| 19 | - * * groupId => array ( |
|
| 20 | - * * * "group" => Group, # GROUP OBJECT |
|
| 21 | - * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
| 22 | - * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
| 23 | - * * * "wins" => int 0, # NUMBER OF WINS |
|
| 24 | - * * * "draws" => int 0, # NUMBER OF DRAWS |
|
| 25 | - * * * "losses" => int 0, # NUMBER OF LOSSES |
|
| 26 | - * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
| 27 | - * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
| 28 | - * * ) |
|
| 29 | - *) |
|
| 30 | - */ |
|
| 17 | + * ARRAY WITH GROUPS AND IT'S RESULTS |
|
| 18 | + * array ( |
|
| 19 | + * * groupId => array ( |
|
| 20 | + * * * "group" => Group, # GROUP OBJECT |
|
| 21 | + * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
| 22 | + * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
| 23 | + * * * "wins" => int 0, # NUMBER OF WINS |
|
| 24 | + * * * "draws" => int 0, # NUMBER OF DRAWS |
|
| 25 | + * * * "losses" => int 0, # NUMBER OF LOSSES |
|
| 26 | + * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
| 27 | + * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
| 28 | + * * ) |
|
| 29 | + *) |
|
| 30 | + */ |
|
| 31 | 31 | public $groupResults = []; |
| 32 | 32 | |
| 33 | 33 | function __construct(string $name = 'team', $id = null) { |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | return $this->sumScore; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function addWin(string $groupId = ''){ |
|
| 107 | + public function addWin(string $groupId = '') { |
|
| 108 | 108 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 109 | 109 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getWinPoints(); |
| 110 | 110 | $this->sumPoints += $this->groupResults[$groupId]['group']->getWinPoints(); |
| 111 | 111 | $this->groupResults[$groupId]['wins']++; |
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | - public function removeWin(string $groupId = ''){ |
|
| 114 | + public function removeWin(string $groupId = '') { |
|
| 115 | 115 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 116 | 116 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getWinPoints(); |
| 117 | 117 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getWinPoints(); |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | return $this; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function addDraw(string $groupId = ''){ |
|
| 122 | + public function addDraw(string $groupId = '') { |
|
| 123 | 123 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 124 | 124 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 125 | 125 | $this->sumPoints += $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 126 | 126 | $this->groupResults[$groupId]['draws']++; |
| 127 | 127 | return $this; |
| 128 | 128 | } |
| 129 | - public function removeDraw(string $groupId = ''){ |
|
| 129 | + public function removeDraw(string $groupId = '') { |
|
| 130 | 130 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 131 | 131 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 132 | 132 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - public function addLoss(string $groupId = ''){ |
|
| 137 | + public function addLoss(string $groupId = '') { |
|
| 138 | 138 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 139 | 139 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getLostPoints(); |
| 140 | 140 | $this->sumPoints += $this->groupResults[$groupId]['group']->getLostPoints(); |
| 141 | 141 | $this->groupResults[$groupId]['losses']++; |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | - public function removeLoss(string $groupId = ''){ |
|
| 144 | + public function removeLoss(string $groupId = '') { |
|
| 145 | 145 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 146 | 146 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getLostPoints(); |
| 147 | 147 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getLostPoints(); |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | return $this; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function addSecond(string $groupId = ''){ |
|
| 152 | + public function addSecond(string $groupId = '') { |
|
| 153 | 153 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 154 | 154 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 155 | 155 | $this->sumPoints += $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 156 | 156 | $this->groupResults[$groupId]['second']++; |
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | - public function removeSecond(string $groupId = ''){ |
|
| 159 | + public function removeSecond(string $groupId = '') { |
|
| 160 | 160 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 161 | 161 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 162 | 162 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | return $this; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function addThird(string $groupId = ''){ |
|
| 167 | + public function addThird(string $groupId = '') { |
|
| 168 | 168 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 169 | 169 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 170 | 170 | $this->sumPoints += $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 171 | 171 | $this->groupResults[$groupId]['third']++; |
| 172 | 172 | return $this; |
| 173 | 173 | } |
| 174 | - public function removeThird(string $groupId = ''){ |
|
| 174 | + public function removeThird(string $groupId = '') { |
|
| 175 | 175 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 176 | 176 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 177 | 177 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
@@ -53,20 +53,26 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | public function getGroupResults($groupId = null) { |
| 55 | 55 | if (isset($groupId)) { |
| 56 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Trying to get unexisting group results ('.$groupId.')'); |
|
| 56 | + if (!isset($this->groupResults[$groupId])) { |
|
| 57 | + throw new \Exception('Trying to get unexisting group results ('.$groupId.')'); |
|
| 58 | + } |
|
| 57 | 59 | return $this->groupResults[$groupId]; |
| 58 | 60 | } |
| 59 | 61 | return $this->groupResults; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | public function addGameWith(Team $team, Group $group) { |
| 63 | - if (!isset($this->gamesWith[$group->getId()][$team->getId()])) $this->gamesWith[$group->getId()][$team->getId()] = 0; |
|
| 65 | + if (!isset($this->gamesWith[$group->getId()][$team->getId()])) { |
|
| 66 | + $this->gamesWith[$group->getId()][$team->getId()] = 0; |
|
| 67 | + } |
|
| 64 | 68 | $this->gamesWith[$group->getId()][$team->getId()]++; |
| 65 | 69 | return $this; |
| 66 | 70 | } |
| 67 | 71 | public function getGameWith(Team $team = null, Group $group = null) { |
| 68 | 72 | if (isset($group)) { |
| 69 | - if (isset($team)) return $this->gamesWith[$group->getId()][$team->getId()]; |
|
| 73 | + if (isset($team)) { |
|
| 74 | + return $this->gamesWith[$group->getId()][$team->getId()]; |
|
| 75 | + } |
|
| 70 | 76 | return $this->gamesWith[$group->getId()]; |
| 71 | 77 | } |
| 72 | 78 | if (isset($team)) { |
@@ -75,25 +81,35 @@ discard block |
||
| 75 | 81 | $filter = array_filter($games, function($key) use ($team){ |
| 76 | 82 | return $key === $team->getId(); |
| 77 | 83 | }, ARRAY_FILTER_USE_KEY); |
| 78 | - if (count($filter) > 0) $return[$id] = $filter; |
|
| 84 | + if (count($filter) > 0) { |
|
| 85 | + $return[$id] = $filter; |
|
| 86 | + } |
|
| 79 | 87 | } |
| 80 | 88 | return $return; |
| 81 | 89 | } |
| 82 | 90 | return $this->gamesWith; |
| 83 | 91 | } |
| 84 | 92 | public function addGroup(Group $group) { |
| 85 | - if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
|
| 93 | + if (!isset($this->games[$group->getId()])) { |
|
| 94 | + $this->games[$group->getId()] = []; |
|
| 95 | + } |
|
| 86 | 96 | return $this; |
| 87 | 97 | } |
| 88 | 98 | public function addGame(Game $game) { |
| 89 | 99 | $group = $game->getGroup(); |
| 90 | - if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
|
| 100 | + if (!isset($this->games[$group->getId()])) { |
|
| 101 | + $this->games[$group->getId()] = []; |
|
| 102 | + } |
|
| 91 | 103 | $this->games[$group->getId()][] = $game; |
| 92 | 104 | return $this; |
| 93 | 105 | } |
| 94 | 106 | public function getGames(Group $group = null, $groupId = null) { |
| 95 | - if (isset($group) && isset($this->games[$group->getId()])) return $this->games[$group->getId()]; |
|
| 96 | - if (isset($groupId) && isset($this->games[$groupId])) return $this->games[$groupId]; |
|
| 107 | + if (isset($group) && isset($this->games[$group->getId()])) { |
|
| 108 | + return $this->games[$group->getId()]; |
|
| 109 | + } |
|
| 110 | + if (isset($groupId) && isset($this->games[$groupId])) { |
|
| 111 | + return $this->games[$groupId]; |
|
| 112 | + } |
|
| 97 | 113 | return $this->games; |
| 98 | 114 | } |
| 99 | 115 | |
@@ -105,14 +121,18 @@ discard block |
||
| 105 | 121 | } |
| 106 | 122 | |
| 107 | 123 | public function addWin(string $groupId = ''){ |
| 108 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 124 | + if (!isset($this->groupResults[$groupId])) { |
|
| 125 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 126 | + } |
|
| 109 | 127 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getWinPoints(); |
| 110 | 128 | $this->sumPoints += $this->groupResults[$groupId]['group']->getWinPoints(); |
| 111 | 129 | $this->groupResults[$groupId]['wins']++; |
| 112 | 130 | return $this; |
| 113 | 131 | } |
| 114 | 132 | public function removeWin(string $groupId = ''){ |
| 115 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 133 | + if (!isset($this->groupResults[$groupId])) { |
|
| 134 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 135 | + } |
|
| 116 | 136 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getWinPoints(); |
| 117 | 137 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getWinPoints(); |
| 118 | 138 | $this->groupResults[$groupId]['wins']--; |
@@ -120,14 +140,18 @@ discard block |
||
| 120 | 140 | } |
| 121 | 141 | |
| 122 | 142 | public function addDraw(string $groupId = ''){ |
| 123 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 143 | + if (!isset($this->groupResults[$groupId])) { |
|
| 144 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 145 | + } |
|
| 124 | 146 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 125 | 147 | $this->sumPoints += $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 126 | 148 | $this->groupResults[$groupId]['draws']++; |
| 127 | 149 | return $this; |
| 128 | 150 | } |
| 129 | 151 | public function removeDraw(string $groupId = ''){ |
| 130 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 152 | + if (!isset($this->groupResults[$groupId])) { |
|
| 153 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 154 | + } |
|
| 131 | 155 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 132 | 156 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
| 133 | 157 | $this->groupResults[$groupId]['draws']--; |
@@ -135,14 +159,18 @@ discard block |
||
| 135 | 159 | } |
| 136 | 160 | |
| 137 | 161 | public function addLoss(string $groupId = ''){ |
| 138 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 162 | + if (!isset($this->groupResults[$groupId])) { |
|
| 163 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 164 | + } |
|
| 139 | 165 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getLostPoints(); |
| 140 | 166 | $this->sumPoints += $this->groupResults[$groupId]['group']->getLostPoints(); |
| 141 | 167 | $this->groupResults[$groupId]['losses']++; |
| 142 | 168 | return $this; |
| 143 | 169 | } |
| 144 | 170 | public function removeLoss(string $groupId = ''){ |
| 145 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 171 | + if (!isset($this->groupResults[$groupId])) { |
|
| 172 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 173 | + } |
|
| 146 | 174 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getLostPoints(); |
| 147 | 175 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getLostPoints(); |
| 148 | 176 | $this->groupResults[$groupId]['losses']--; |
@@ -150,14 +178,18 @@ discard block |
||
| 150 | 178 | } |
| 151 | 179 | |
| 152 | 180 | public function addSecond(string $groupId = ''){ |
| 153 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 181 | + if (!isset($this->groupResults[$groupId])) { |
|
| 182 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 183 | + } |
|
| 154 | 184 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 155 | 185 | $this->sumPoints += $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 156 | 186 | $this->groupResults[$groupId]['second']++; |
| 157 | 187 | return $this; |
| 158 | 188 | } |
| 159 | 189 | public function removeSecond(string $groupId = ''){ |
| 160 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 190 | + if (!isset($this->groupResults[$groupId])) { |
|
| 191 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 192 | + } |
|
| 161 | 193 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 162 | 194 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
| 163 | 195 | $this->groupResults[$groupId]['second']--; |
@@ -165,14 +197,18 @@ discard block |
||
| 165 | 197 | } |
| 166 | 198 | |
| 167 | 199 | public function addThird(string $groupId = ''){ |
| 168 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 200 | + if (!isset($this->groupResults[$groupId])) { |
|
| 201 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 202 | + } |
|
| 169 | 203 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 170 | 204 | $this->sumPoints += $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 171 | 205 | $this->groupResults[$groupId]['third']++; |
| 172 | 206 | return $this; |
| 173 | 207 | } |
| 174 | 208 | public function removeThird(string $groupId = ''){ |
| 175 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 209 | + if (!isset($this->groupResults[$groupId])) { |
|
| 210 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
| 211 | + } |
|
| 176 | 212 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 177 | 213 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
| 178 | 214 | $this->groupResults[$groupId]['third']--; |
@@ -180,7 +216,9 @@ discard block |
||
| 180 | 216 | } |
| 181 | 217 | |
| 182 | 218 | public function sumPoints(array $groupIds = []) { |
| 183 | - if (count($groupIds) === 0) return $this->sumPoints; |
|
| 219 | + if (count($groupIds) === 0) { |
|
| 220 | + return $this->sumPoints; |
|
| 221 | + } |
|
| 184 | 222 | $sum = 0; |
| 185 | 223 | foreach ($groupIds as $gid) { |
| 186 | 224 | $sum += $this->groupResults[$gid]['points'] ?? 0; |
@@ -188,7 +226,9 @@ discard block |
||
| 188 | 226 | return $sum; |
| 189 | 227 | } |
| 190 | 228 | public function sumScore(array $groupIds = []) { |
| 191 | - if (count($groupIds) === 0) return $this->sumScore; |
|
| 229 | + if (count($groupIds) === 0) { |
|
| 230 | + return $this->sumScore; |
|
| 231 | + } |
|
| 192 | 232 | $sum = 0; |
| 193 | 233 | foreach ($groupIds as $gid) { |
| 194 | 234 | $sum += $this->groupResults[$gid]['score'] ?? 0; |
@@ -38,12 +38,20 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function progress(bool $blank = false) { |
| 41 | - if ($this->progressed) return $this; |
|
| 42 | - if ($blank) $teams = $this->from->isPlayed() ? $this->from->sortTeams(null, $this->filters) : $this->from->simulate($this->filters); |
|
| 43 | - else $teams = $this->from->sortTeams(null, $this->filters); |
|
| 41 | + if ($this->progressed) { |
|
| 42 | + return $this; |
|
| 43 | + } |
|
| 44 | + if ($blank) { |
|
| 45 | + $teams = $this->from->isPlayed() ? $this->from->sortTeams(null, $this->filters) : $this->from->simulate($this->filters); |
|
| 46 | + } else { |
|
| 47 | + $teams = $this->from->sortTeams(null, $this->filters); |
|
| 48 | + } |
|
| 44 | 49 | |
| 45 | - if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
| 46 | - else $next = $teams; |
|
| 50 | + if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) { |
|
| 51 | + $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
| 52 | + } else { |
|
| 53 | + $next = $teams; |
|
| 54 | + } |
|
| 47 | 55 | |
| 48 | 56 | $i = 1; |
| 49 | 57 | |
@@ -51,12 +59,15 @@ discard block |
||
| 51 | 59 | if ($blank) { |
| 52 | 60 | $this->to->addTeam(new BlankTeam($this.' - '.$i, $team, $this->from, $this)); |
| 53 | 61 | $i++; |
| 62 | + } else { |
|
| 63 | + $team->addPoints($this->from->getProgressPoints()); |
|
| 54 | 64 | } |
| 55 | - else $team->addPoints($this->from->getProgressPoints()); |
|
| 56 | 65 | } |
| 57 | 66 | |
| 58 | 67 | $this->from->addProgressed($next); |
| 59 | - if (!$blank) $this->to->addTeam($next); |
|
| 68 | + if (!$blank) { |
|
| 69 | + $this->to->addTeam($next); |
|
| 70 | + } |
|
| 60 | 71 | $this->progressed = true; |
| 61 | 72 | return $this; |
| 62 | 73 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | $this->setId(isset($id) ? $id : uniqid()); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function allowSkip(){ |
|
| 31 | + public function allowSkip() { |
|
| 32 | 32 | $this->generator->allowSkip(); |
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | - public function disallowSkip(){ |
|
| 35 | + public function disallowSkip() { |
|
| 36 | 36 | $this->generator->disallowSkip(); |
| 37 | 37 | return $this; |
| 38 | 38 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function addTeam(...$teams) { |
| 48 | - \array_walk_recursive($teams, function($team){ |
|
| 48 | + \array_walk_recursive($teams, function($team) { |
|
| 49 | 49 | $this->setTeam($team); |
| 50 | 50 | }); |
| 51 | 51 | return $this; |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | return $this; |
| 179 | 179 | } |
| 180 | 180 | public function addProgressed(...$teams) { |
| 181 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($teams, function($a){return $a instanceof Team;}))); |
|
| 182 | - foreach (array_filter($teams, function($a){return is_array($a);}) as $team) { |
|
| 183 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($team, function($a) { |
|
| 181 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($teams, function($a) {return $a instanceof Team; }))); |
|
| 182 | + foreach (array_filter($teams, function($a) {return is_array($a); }) as $team) { |
|
| 183 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($team, function($a) { |
|
| 184 | 184 | return ($a instanceof Team); |
| 185 | 185 | }))); |
| 186 | 186 | } |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | $this->games[] = $g; |
| 201 | 201 | return $g; |
| 202 | 202 | } |
| 203 | - public function addGame(...$games){ |
|
| 204 | - array_walk_recursive($games, function($game){ |
|
| 203 | + public function addGame(...$games) { |
|
| 204 | + array_walk_recursive($games, function($game) { |
|
| 205 | 205 | if ($game instanceof Game) $this->games[] = $game; |
| 206 | 206 | }); |
| 207 | 207 | return $this; |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | return $this; |
| 226 | 226 | } |
| 227 | - public function isPlayed(){ |
|
| 227 | + public function isPlayed() { |
|
| 228 | 228 | if (count($this->games) === 0) return false; |
| 229 | - return count(array_filter($this->games, function($a){return $a->isPlayed();})) !== 0; |
|
| 229 | + return count(array_filter($this->games, function($a) {return $a->isPlayed(); })) !== 0; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | } |
@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | public function getTeams(bool $ordered = false, $ordering = \TournamentGenerator\Constants::POINTS, array $filters = []) { |
| 59 | 59 | $teams = $this->teams; |
| 60 | 60 | |
| 61 | - if ($ordered) return $this->sortTeams($ordering, $filters); |
|
| 61 | + if ($ordered) { |
|
| 62 | + return $this->sortTeams($ordering, $filters); |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | // APPLY FILTERS |
| 64 | 66 | $filter = new Filter([$this], $filters); |
@@ -73,7 +75,9 @@ discard block |
||
| 73 | 75 | return $t; |
| 74 | 76 | } |
| 75 | 77 | public function sortTeams($ordering = null, array $filters = []) { |
| 76 | - if (!isset($ordering)) $ordering = $this->ordering; |
|
| 78 | + if (!isset($ordering)) { |
|
| 79 | + $ordering = $this->ordering; |
|
| 80 | + } |
|
| 77 | 81 | $this->teams = Utilis\Sorter\Teams::sortGroup($this->teams, $this, $ordering); |
| 78 | 82 | return $this->getTeams(false, null, $filters); |
| 79 | 83 | } |
@@ -146,7 +150,9 @@ discard block |
||
| 146 | 150 | } |
| 147 | 151 | |
| 148 | 152 | public function setOrdering(string $ordering = \TournamentGenerator\Constants::POINTS) { |
| 149 | - if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 153 | + if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) { |
|
| 154 | + throw new \Exception('Unknown group ordering: '.$ordering); |
|
| 155 | + } |
|
| 150 | 156 | $this->ordering = $ordering; |
| 151 | 157 | return $this; |
| 152 | 158 | } |
@@ -202,7 +208,9 @@ discard block |
||
| 202 | 208 | } |
| 203 | 209 | public function addGame(...$games){ |
| 204 | 210 | array_walk_recursive($games, function($game){ |
| 205 | - if ($game instanceof Game) $this->games[] = $game; |
|
| 211 | + if ($game instanceof Game) { |
|
| 212 | + $this->games[] = $game; |
|
| 213 | + } |
|
| 206 | 214 | }); |
| 207 | 215 | return $this; |
| 208 | 216 | } |
@@ -210,7 +218,9 @@ discard block |
||
| 210 | 218 | return $this->games; |
| 211 | 219 | } |
| 212 | 220 | public function orderGames() { |
| 213 | - if (count($this->games) <= 4) return $this->games; |
|
| 221 | + if (count($this->games) <= 4) { |
|
| 222 | + return $this->games; |
|
| 223 | + } |
|
| 214 | 224 | $this->games = $this->generator->orderGames(); |
| 215 | 225 | return $this->games; |
| 216 | 226 | } |
@@ -225,7 +235,9 @@ discard block |
||
| 225 | 235 | return $this; |
| 226 | 236 | } |
| 227 | 237 | public function isPlayed(){ |
| 228 | - if (count($this->games) === 0) return false; |
|
| 238 | + if (count($this->games) === 0) { |
|
| 239 | + return false; |
|
| 240 | + } |
|
| 229 | 241 | return count(array_filter($this->games, function($a){return $a->isPlayed();})) !== 0; |
| 230 | 242 | } |
| 231 | 243 | |