@@ -106,7 +106,9 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getGroupResults($groupId = null) { |
108 | 108 | if (isset($groupId)) { |
109 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Trying to get unexisting group results ('.$groupId.')'); |
|
109 | + if (!isset($this->groupResults[$groupId])) { |
|
110 | + throw new \Exception('Trying to get unexisting group results ('.$groupId.')'); |
|
111 | + } |
|
110 | 112 | return $this->groupResults[$groupId]; |
111 | 113 | } |
112 | 114 | return $this->groupResults; |
@@ -121,7 +123,9 @@ discard block |
||
121 | 123 | * @return self |
122 | 124 | */ |
123 | 125 | public function addGameWith(Team $team, Group $group) { |
124 | - if (!isset($this->gamesWith[$group->getId()][$team->getId()])) $this->gamesWith[$group->getId()][$team->getId()] = 0; |
|
126 | + if (!isset($this->gamesWith[$group->getId()][$team->getId()])) { |
|
127 | + $this->gamesWith[$group->getId()][$team->getId()] = 0; |
|
128 | + } |
|
125 | 129 | $this->gamesWith[$group->getId()][$team->getId()]++; |
126 | 130 | return $this; |
127 | 131 | } |
@@ -135,7 +139,9 @@ discard block |
||
135 | 139 | */ |
136 | 140 | public function getGameWith(Team $team = null, Group $group = null) { |
137 | 141 | if (isset($group)) { |
138 | - if (isset($team)) return $this->gamesWith[$group->getId()][$team->getId()]; |
|
142 | + if (isset($team)) { |
|
143 | + return $this->gamesWith[$group->getId()][$team->getId()]; |
|
144 | + } |
|
139 | 145 | return $this->gamesWith[$group->getId()]; |
140 | 146 | } |
141 | 147 | if (isset($team)) { |
@@ -144,7 +150,9 @@ discard block |
||
144 | 150 | $filter = array_filter($games, function($key) use ($team){ |
145 | 151 | return $key === $team->getId(); |
146 | 152 | }, ARRAY_FILTER_USE_KEY); |
147 | - if (count($filter) > 0) $return[$id] = $filter; |
|
153 | + if (count($filter) > 0) { |
|
154 | + $return[$id] = $filter; |
|
155 | + } |
|
148 | 156 | } |
149 | 157 | return $return; |
150 | 158 | } |
@@ -158,7 +166,9 @@ discard block |
||
158 | 166 | * @return self |
159 | 167 | */ |
160 | 168 | public function addGroup(Group $group) { |
161 | - if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
|
169 | + if (!isset($this->games[$group->getId()])) { |
|
170 | + $this->games[$group->getId()] = []; |
|
171 | + } |
|
162 | 172 | return $this; |
163 | 173 | } |
164 | 174 | /** |
@@ -170,7 +180,9 @@ discard block |
||
170 | 180 | */ |
171 | 181 | public function addGame(Game $game) { |
172 | 182 | $group = $game->getGroup(); |
173 | - if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
|
183 | + if (!isset($this->games[$group->getId()])) { |
|
184 | + $this->games[$group->getId()] = []; |
|
185 | + } |
|
174 | 186 | $this->games[$group->getId()][] = $game; |
175 | 187 | return $this; |
176 | 188 | } |
@@ -183,8 +195,12 @@ discard block |
||
183 | 195 | * @return array Games from a group or all games if both arguments are null |
184 | 196 | */ |
185 | 197 | public function getGames(Group $group = null, $groupId = null) { |
186 | - if (isset($group) && isset($this->games[$group->getId()])) return $this->games[$group->getId()]; |
|
187 | - if (isset($groupId) && isset($this->games[$groupId])) return $this->games[$groupId]; |
|
198 | + if (isset($group) && isset($this->games[$group->getId()])) { |
|
199 | + return $this->games[$group->getId()]; |
|
200 | + } |
|
201 | + if (isset($groupId) && isset($this->games[$groupId])) { |
|
202 | + return $this->games[$groupId]; |
|
203 | + } |
|
188 | 204 | return $this->games; |
189 | 205 | } |
190 | 206 | |
@@ -217,7 +233,9 @@ discard block |
||
217 | 233 | * @return self |
218 | 234 | */ |
219 | 235 | public function addWin(string $groupId = ''){ |
220 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
236 | + if (!isset($this->groupResults[$groupId])) { |
|
237 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
238 | + } |
|
221 | 239 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getWinPoints(); |
222 | 240 | $this->sumPoints += $this->groupResults[$groupId]['group']->getWinPoints(); |
223 | 241 | $this->groupResults[$groupId]['wins']++; |
@@ -235,7 +253,9 @@ discard block |
||
235 | 253 | * @return self |
236 | 254 | */ |
237 | 255 | public function removeWin(string $groupId = ''){ |
238 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
256 | + if (!isset($this->groupResults[$groupId])) { |
|
257 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
258 | + } |
|
239 | 259 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getWinPoints(); |
240 | 260 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getWinPoints(); |
241 | 261 | $this->groupResults[$groupId]['wins']--; |
@@ -254,7 +274,9 @@ discard block |
||
254 | 274 | * @return self |
255 | 275 | */ |
256 | 276 | public function addDraw(string $groupId = ''){ |
257 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
277 | + if (!isset($this->groupResults[$groupId])) { |
|
278 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
279 | + } |
|
258 | 280 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getDrawPoints(); |
259 | 281 | $this->sumPoints += $this->groupResults[$groupId]['group']->getDrawPoints(); |
260 | 282 | $this->groupResults[$groupId]['draws']++; |
@@ -272,7 +294,9 @@ discard block |
||
272 | 294 | * @return self |
273 | 295 | */ |
274 | 296 | public function removeDraw(string $groupId = ''){ |
275 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
297 | + if (!isset($this->groupResults[$groupId])) { |
|
298 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
299 | + } |
|
276 | 300 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
277 | 301 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
278 | 302 | $this->groupResults[$groupId]['draws']--; |
@@ -291,7 +315,9 @@ discard block |
||
291 | 315 | * @return self |
292 | 316 | */ |
293 | 317 | public function addLoss(string $groupId = ''){ |
294 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
318 | + if (!isset($this->groupResults[$groupId])) { |
|
319 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
320 | + } |
|
295 | 321 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getLostPoints(); |
296 | 322 | $this->sumPoints += $this->groupResults[$groupId]['group']->getLostPoints(); |
297 | 323 | $this->groupResults[$groupId]['losses']++; |
@@ -309,7 +335,9 @@ discard block |
||
309 | 335 | * @return self |
310 | 336 | */ |
311 | 337 | public function removeLoss(string $groupId = ''){ |
312 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
338 | + if (!isset($this->groupResults[$groupId])) { |
|
339 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
340 | + } |
|
313 | 341 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getLostPoints(); |
314 | 342 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getLostPoints(); |
315 | 343 | $this->groupResults[$groupId]['losses']--; |
@@ -328,7 +356,9 @@ discard block |
||
328 | 356 | * @return self |
329 | 357 | */ |
330 | 358 | public function addSecond(string $groupId = ''){ |
331 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
359 | + if (!isset($this->groupResults[$groupId])) { |
|
360 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
361 | + } |
|
332 | 362 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getSecondPoints(); |
333 | 363 | $this->sumPoints += $this->groupResults[$groupId]['group']->getSecondPoints(); |
334 | 364 | $this->groupResults[$groupId]['second']++; |
@@ -346,7 +376,9 @@ discard block |
||
346 | 376 | * @return self |
347 | 377 | */ |
348 | 378 | public function removeSecond(string $groupId = ''){ |
349 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
379 | + if (!isset($this->groupResults[$groupId])) { |
|
380 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
381 | + } |
|
350 | 382 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
351 | 383 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
352 | 384 | $this->groupResults[$groupId]['second']--; |
@@ -365,7 +397,9 @@ discard block |
||
365 | 397 | * @return self |
366 | 398 | */ |
367 | 399 | public function addThird(string $groupId = ''){ |
368 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
400 | + if (!isset($this->groupResults[$groupId])) { |
|
401 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
402 | + } |
|
369 | 403 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getThirdPoints(); |
370 | 404 | $this->sumPoints += $this->groupResults[$groupId]['group']->getThirdPoints(); |
371 | 405 | $this->groupResults[$groupId]['third']++; |
@@ -383,7 +417,9 @@ discard block |
||
383 | 417 | * @return self |
384 | 418 | */ |
385 | 419 | public function removeThird(string $groupId = ''){ |
386 | - if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
420 | + if (!isset($this->groupResults[$groupId])) { |
|
421 | + throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
|
422 | + } |
|
387 | 423 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
388 | 424 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
389 | 425 | $this->groupResults[$groupId]['third']--; |
@@ -398,7 +434,9 @@ discard block |
||
398 | 434 | * @return int Sum of the points or sum of all points if argument is empty |
399 | 435 | */ |
400 | 436 | public function sumPoints(array $groupIds = []) { |
401 | - if (count($groupIds) === 0) return $this->sumPoints; |
|
437 | + if (count($groupIds) === 0) { |
|
438 | + return $this->sumPoints; |
|
439 | + } |
|
402 | 440 | $sum = 0; |
403 | 441 | foreach ($groupIds as $gid) { |
404 | 442 | $sum += $this->groupResults[$gid]['points'] ?? 0; |
@@ -413,7 +451,9 @@ discard block |
||
413 | 451 | * @return int Sum of score or sum of all score if argument is empty |
414 | 452 | */ |
415 | 453 | public function sumScore(array $groupIds = []) { |
416 | - if (count($groupIds) === 0) return $this->sumScore; |
|
454 | + if (count($groupIds) === 0) { |
|
455 | + return $this->sumScore; |
|
456 | + } |
|
417 | 457 | $sum = 0; |
418 | 458 | foreach ($groupIds as $gid) { |
419 | 459 | $sum += $this->groupResults[$gid]['score'] ?? 0; |