@@ -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 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | return $this; |
| 185 | 185 | } |
| 186 | 186 | public function addProgressed(...$teams) { |
| 187 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($teams, function($a){return $a instanceof Team;}))); |
|
| 188 | - foreach (array_filter($teams, function($a){return is_array($a);}) as $team) { |
|
| 189 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($team, function($a) { |
|
| 187 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($teams, function($a) {return $a instanceof Team; }))); |
|
| 188 | + foreach (array_filter($teams, function($a) {return is_array($a); }) as $team) { |
|
| 189 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($team, function($a) { |
|
| 190 | 190 | return ($a instanceof Team); |
| 191 | 191 | }))); |
| 192 | 192 | } |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | $this->games[] = $g; |
| 207 | 207 | return $g; |
| 208 | 208 | } |
| 209 | - public function addGame(...$games){ |
|
| 210 | - $this->games = array_merge($this->games, array_filter($games, function($a){ return ($a instanceof Game); })); |
|
| 209 | + public function addGame(...$games) { |
|
| 210 | + $this->games = array_merge($this->games, array_filter($games, function($a) { return ($a instanceof Game); })); |
|
| 211 | 211 | |
| 212 | - foreach (array_filter($games, function($a){return is_array($a);}) as $key => $game) { |
|
| 213 | - $this->games = array_merge($this->games, array_filter($game, function($a){ return ($a instanceof Game); })); |
|
| 212 | + foreach (array_filter($games, function($a) {return is_array($a); }) as $key => $game) { |
|
| 213 | + $this->games = array_merge($this->games, array_filter($game, function($a) { return ($a instanceof Game); })); |
|
| 214 | 214 | } |
| 215 | 215 | return $this; |
| 216 | 216 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | return $this; |
| 234 | 234 | } |
| 235 | - public function isPlayed(){ |
|
| 235 | + public function isPlayed() { |
|
| 236 | 236 | if (count($this->games) === 0) return false; |
| 237 | 237 | foreach ($this->games as $game) { |
| 238 | 238 | if (!$game->isPlayed()) return false; |
@@ -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(); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | if (count($error) > 0) throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true)); |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | - public function getTeams(){ |
|
| 69 | + public function getTeams() { |
|
| 70 | 70 | return $this->teams; |
| 71 | 71 | } |
| 72 | - public function getTeamsIds(){ |
|
| 73 | - return array_map(function($a){ return $a->getId(); }, $this->teams); |
|
| 72 | + public function getTeamsIds() { |
|
| 73 | + return array_map(function($a) { return $a->getId(); }, $this->teams); |
|
| 74 | 74 | } |
| 75 | 75 | public function getTeam($id) { |
| 76 | - $key = array_search($id, array_map(function($a){ return $a->getId();}, $this->teams)); |
|
| 76 | + $key = array_search($id, array_map(function($a) { return $a->getId(); }, $this->teams)); |
|
| 77 | 77 | return ($key !== false ? $this->teams[$key] : false); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | private function setResults2($i, $score, $results, $team) { |
| 113 | - if (count(array_filter($results, function($a) use ($score){return $a === $score;})) > 1) { |
|
| 113 | + if (count(array_filter($results, function($a) use ($score){return $a === $score; })) > 1) { |
|
| 114 | 114 | $this->drawIds[] = $team->getId(); |
| 115 | 115 | $team->addDraw($this->group->getId()); |
| 116 | 116 | $this->results[$team->getId()] += ['points' => $this->group->getDrawPoints(), 'type' => 'draw']; |