@@ -24,33 +24,33 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | - * Sets the name of the object |
|
28 | - * |
|
29 | - * @param string $name Name of the object |
|
30 | - * |
|
31 | - * @return self |
|
32 | - */ |
|
27 | + * Sets the name of the object |
|
28 | + * |
|
29 | + * @param string $name Name of the object |
|
30 | + * |
|
31 | + * @return self |
|
32 | + */ |
|
33 | 33 | public function setName(string $name) { |
34 | 34 | $this->name = $name; |
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | /** |
38 | - * Gets the name of the object |
|
39 | - * |
|
40 | - * @return string Name of the object |
|
41 | - */ |
|
38 | + * Gets the name of the object |
|
39 | + * |
|
40 | + * @return string Name of the object |
|
41 | + */ |
|
42 | 42 | public function getName() { |
43 | 43 | return $this->name; |
44 | 44 | } |
45 | 45 | /** |
46 | - * Sets the unique identifier of the object |
|
47 | - * |
|
48 | - * @param string|int $id Unique identifier of the object |
|
49 | - * |
|
50 | - * @throws \InvalidArgumentException if the provided argument is not of type 'string' or 'int' |
|
51 | - * |
|
52 | - * @return self |
|
53 | - */ |
|
46 | + * Sets the unique identifier of the object |
|
47 | + * |
|
48 | + * @param string|int $id Unique identifier of the object |
|
49 | + * |
|
50 | + * @throws \InvalidArgumentException if the provided argument is not of type 'string' or 'int' |
|
51 | + * |
|
52 | + * @return self |
|
53 | + */ |
|
54 | 54 | public function setId($id) { |
55 | 55 | if (!is_string($id) && !is_int($id)) { |
56 | 56 | $this->id = uniqid(); |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | /** |
63 | - * Gets the unique identifier of the object |
|
64 | - * |
|
65 | - * @return string Unique identifier of the object |
|
66 | - */ |
|
63 | + * Gets the unique identifier of the object |
|
64 | + * |
|
65 | + * @return string Unique identifier of the object |
|
66 | + */ |
|
67 | 67 | public function getId() { |
68 | 68 | return $this->id; |
69 | 69 | } |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | /** |
17 | - * @var string $name The name of the team |
|
18 | - * @var string|int $id The unique identifier of the team |
|
19 | - */ |
|
17 | + * @var string $name The name of the team |
|
18 | + * @var string|int $id The unique identifier of the team |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** @var array $games A list of games played by this team */ |
22 | 22 | protected $games = []; |
@@ -31,57 +31,57 @@ discard block |
||
31 | 31 | protected $sumScore = 0; |
32 | 32 | |
33 | 33 | /** |
34 | - * @var array $groupResults Associative array of results in each group |
|
35 | - * |
|
36 | - * array ( |
|
37 | - * * groupId => array ( |
|
38 | - * * * "group" => Group, # GROUP OBJECT |
|
39 | - * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
40 | - * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
41 | - * * * "wins" => int 0, # NUMBER OF WINS |
|
42 | - * * * "draws" => int 0, # NUMBER OF DRAWS |
|
43 | - * * * "losses" => int 0, # NUMBER OF LOSSES |
|
44 | - * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
45 | - * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
46 | - * * ) |
|
47 | - *) |
|
48 | - */ |
|
34 | + * @var array $groupResults Associative array of results in each group |
|
35 | + * |
|
36 | + * array ( |
|
37 | + * * groupId => array ( |
|
38 | + * * * "group" => Group, # GROUP OBJECT |
|
39 | + * * * "points" => int 0, # NUMBER OF POINTS AQUIRED |
|
40 | + * * * "score" => int 0, # SUM OF SCORE AQUIRED |
|
41 | + * * * "wins" => int 0, # NUMBER OF WINS |
|
42 | + * * * "draws" => int 0, # NUMBER OF DRAWS |
|
43 | + * * * "losses" => int 0, # NUMBER OF LOSSES |
|
44 | + * * * "second" => int 0, # NUMBER OF TIMES BEING SECOND (ONLY FOR INGAME OPTION OF 3 OR 4) |
|
45 | + * * * "third" => int 0 # NUMBER OF TIMES BEING THIRD (ONLY FOR INGAME OPTION OF 4) |
|
46 | + * * ) |
|
47 | + *) |
|
48 | + */ |
|
49 | 49 | public $groupResults = []; |
50 | 50 | |
51 | 51 | /** |
52 | - * Initiates a team class |
|
53 | - * |
|
54 | - * @param string $name Name of the team |
|
55 | - * @param string|int $id Unique identifier of the team |
|
56 | - * |
|
57 | - * @throws \InvalidArgumentException if the provided argument id is not of type 'null' or 'string' or 'int' |
|
58 | - */ |
|
52 | + * Initiates a team class |
|
53 | + * |
|
54 | + * @param string $name Name of the team |
|
55 | + * @param string|int $id Unique identifier of the team |
|
56 | + * |
|
57 | + * @throws \InvalidArgumentException if the provided argument id is not of type 'null' or 'string' or 'int' |
|
58 | + */ |
|
59 | 59 | function __construct(string $name = 'team', $id = null) { |
60 | 60 | $this->setName($name); |
61 | 61 | $this->setId(isset($id) ? $id : uniqid()); |
62 | 62 | } |
63 | 63 | /** |
64 | - * Gets team statistics from the given group without the group object |
|
65 | - * |
|
66 | - * @param string|int $groupId Unique identifier of the group to get its results |
|
67 | - * |
|
68 | - * @throws \Exception if the group with given groupId doesn't exist |
|
69 | - * |
|
70 | - * @return array All the statistics including points, score, wins, draws, losses, times being second, times being third |
|
71 | - */ |
|
64 | + * Gets team statistics from the given group without the group object |
|
65 | + * |
|
66 | + * @param string|int $groupId Unique identifier of the group to get its results |
|
67 | + * |
|
68 | + * @throws \Exception if the group with given groupId doesn't exist |
|
69 | + * |
|
70 | + * @return array All the statistics including points, score, wins, draws, losses, times being second, times being third |
|
71 | + */ |
|
72 | 72 | public function getGamesInfo($groupId) { |
73 | 73 | return array_filter($this->getGroupResults($groupId), function($k) { return $k !== 'group'; }, ARRAY_FILTER_USE_KEY); |
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Creates a new data-array to store statistics for a new group |
|
78 | - * |
|
79 | - * Resets the statistics if the group was already added |
|
80 | - * |
|
81 | - * @param Group $group A group object to add its results |
|
82 | - * |
|
83 | - * @return self |
|
84 | - */ |
|
77 | + * Creates a new data-array to store statistics for a new group |
|
78 | + * |
|
79 | + * Resets the statistics if the group was already added |
|
80 | + * |
|
81 | + * @param Group $group A group object to add its results |
|
82 | + * |
|
83 | + * @return self |
|
84 | + */ |
|
85 | 85 | public function addGroupResults(Group $group) { |
86 | 86 | $this->groupResults[$group->getId()] = [ |
87 | 87 | 'group' => $group, |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | /** |
99 | - * Gets team statistics from the given group |
|
100 | - * |
|
101 | - * @param string|int|null $groupId Unique identifier of the group to get its results |
|
102 | - * |
|
103 | - * @throws \Exception if the group with given groupId doesn't exist |
|
104 | - * |
|
105 | - * @return array All the statistics including points, score, wins, draws, losses, times being second, times being third if the group id is set or all the statistics |
|
106 | - */ |
|
99 | + * Gets team statistics from the given group |
|
100 | + * |
|
101 | + * @param string|int|null $groupId Unique identifier of the group to get its results |
|
102 | + * |
|
103 | + * @throws \Exception if the group with given groupId doesn't exist |
|
104 | + * |
|
105 | + * @return array All the statistics including points, score, wins, draws, losses, times being second, times being third if the group id is set or all the statistics |
|
106 | + */ |
|
107 | 107 | public function getGroupResults($groupId = null) { |
108 | 108 | if (isset($groupId)) { |
109 | 109 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Trying to get unexisting group results ('.$groupId.')'); |
@@ -113,26 +113,26 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | - * Adds a record of a game with another team in a group |
|
117 | - * |
|
118 | - * @param Team $team A team that played with this team |
|
119 | - * @param Group $group A group that the teams were playing in |
|
120 | - * |
|
121 | - * @return self |
|
122 | - */ |
|
116 | + * Adds a record of a game with another team in a group |
|
117 | + * |
|
118 | + * @param Team $team A team that played with this team |
|
119 | + * @param Group $group A group that the teams were playing in |
|
120 | + * |
|
121 | + * @return self |
|
122 | + */ |
|
123 | 123 | public function addGameWith(Team $team, Group $group) { |
124 | 124 | if (!isset($this->gamesWith[$group->getId()][$team->getId()])) $this->gamesWith[$group->getId()][$team->getId()] = 0; |
125 | 125 | $this->gamesWith[$group->getId()][$team->getId()]++; |
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | /** |
129 | - * Gets a record of a game with another team or teams |
|
130 | - * |
|
131 | - * @param Team|null $team A team to get the games with |
|
132 | - * @param Group|null $group A group from where to get the games |
|
133 | - * |
|
134 | - * @return array|int The number of games played with a team in a group if both arguments are given, array of all games with all teams from a group if only group is given, array of games with team from all groups if only a team argument is given or all games with all teams from all groups if no argument is given |
|
135 | - */ |
|
129 | + * Gets a record of a game with another team or teams |
|
130 | + * |
|
131 | + * @param Team|null $team A team to get the games with |
|
132 | + * @param Group|null $group A group from where to get the games |
|
133 | + * |
|
134 | + * @return array|int The number of games played with a team in a group if both arguments are given, array of all games with all teams from a group if only group is given, array of games with team from all groups if only a team argument is given or all games with all teams from all groups if no argument is given |
|
135 | + */ |
|
136 | 136 | public function getGameWith(Team $team = null, Group $group = null) { |
137 | 137 | if (isset($group)) { |
138 | 138 | if (isset($team)) return $this->gamesWith[$group->getId()][$team->getId()]; |
@@ -151,23 +151,23 @@ discard block |
||
151 | 151 | return $this->gamesWith; |
152 | 152 | } |
153 | 153 | /** |
154 | - * Adds a group to a team and creates an array for all games to be played |
|
155 | - * |
|
156 | - * @param Group $group A group to add |
|
157 | - * |
|
158 | - * @return self |
|
159 | - */ |
|
154 | + * Adds a group to a team and creates an array for all games to be played |
|
155 | + * |
|
156 | + * @param Group $group A group to add |
|
157 | + * |
|
158 | + * @return self |
|
159 | + */ |
|
160 | 160 | public function addGroup(Group $group) { |
161 | 161 | if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | /** |
165 | - * Adds a game to this team |
|
166 | - * |
|
167 | - * @param Game $game A game to add |
|
168 | - * |
|
169 | - * @return self |
|
170 | - */ |
|
165 | + * Adds a game to this team |
|
166 | + * |
|
167 | + * @param Game $game A game to add |
|
168 | + * |
|
169 | + * @return self |
|
170 | + */ |
|
171 | 171 | public function addGame(Game $game) { |
172 | 172 | $group = $game->getGroup(); |
173 | 173 | if (!isset($this->games[$group->getId()])) $this->games[$group->getId()] = []; |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | return $this; |
176 | 176 | } |
177 | 177 | /** |
178 | - * Gets all game from given group |
|
179 | - * |
|
180 | - * @param Group|null $group A group to get its game from |
|
181 | - * @param string|int|null $groupId An id of group to get its game from |
|
182 | - * |
|
183 | - * @return array Games from a group or all games if both arguments are null |
|
184 | - */ |
|
178 | + * Gets all game from given group |
|
179 | + * |
|
180 | + * @param Group|null $group A group to get its game from |
|
181 | + * @param string|int|null $groupId An id of group to get its game from |
|
182 | + * |
|
183 | + * @return array Games from a group or all games if both arguments are null |
|
184 | + */ |
|
185 | 185 | public function getGames(Group $group = null, $groupId = null) { |
186 | 186 | if (isset($group) && isset($this->games[$group->getId()])) return $this->games[$group->getId()]; |
187 | 187 | if (isset($groupId) && isset($this->games[$groupId])) return $this->games[$groupId]; |
@@ -189,33 +189,33 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * Gets all points that the team has acquired through the tournament |
|
193 | - * |
|
194 | - * @return int Sum of the points acquired |
|
195 | - */ |
|
192 | + * Gets all points that the team has acquired through the tournament |
|
193 | + * |
|
194 | + * @return int Sum of the points acquired |
|
195 | + */ |
|
196 | 196 | public function getSumPoints() { |
197 | 197 | return $this->sumPoints; |
198 | 198 | } |
199 | 199 | /** |
200 | - * Gets all score that the team has acquired through the tournament |
|
201 | - * |
|
202 | - * @return int Sum of the score acquired |
|
203 | - */ |
|
200 | + * Gets all score that the team has acquired through the tournament |
|
201 | + * |
|
202 | + * @return int Sum of the score acquired |
|
203 | + */ |
|
204 | 204 | public function getSumScore() { |
205 | 205 | return $this->sumScore; |
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * Adds a win points to the team |
|
210 | - * |
|
211 | - * @param string|int|null $groupId An id of group to add the results from |
|
212 | - * |
|
213 | - * @throws \Exception if the group results have not been added |
|
214 | - * |
|
215 | - * @uses Group::getWinPoints() to retrieve the points to add |
|
216 | - * |
|
217 | - * @return self |
|
218 | - */ |
|
209 | + * Adds a win points to the team |
|
210 | + * |
|
211 | + * @param string|int|null $groupId An id of group to add the results from |
|
212 | + * |
|
213 | + * @throws \Exception if the group results have not been added |
|
214 | + * |
|
215 | + * @uses Group::getWinPoints() to retrieve the points to add |
|
216 | + * |
|
217 | + * @return self |
|
218 | + */ |
|
219 | 219 | public function addWin(string $groupId = ''){ |
220 | 220 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
221 | 221 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getWinPoints(); |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | return $this; |
225 | 225 | } |
226 | 226 | /** |
227 | - * Remove win points to the team |
|
228 | - * |
|
229 | - * @param string|int|null $groupId An id of group to add the results from |
|
230 | - * |
|
231 | - * @throws \Exception if the group results have not been added |
|
232 | - * |
|
233 | - * @uses Group::getWinPoints() to retrieve the points to add |
|
234 | - * |
|
235 | - * @return self |
|
236 | - */ |
|
227 | + * Remove win points to the team |
|
228 | + * |
|
229 | + * @param string|int|null $groupId An id of group to add the results from |
|
230 | + * |
|
231 | + * @throws \Exception if the group results have not been added |
|
232 | + * |
|
233 | + * @uses Group::getWinPoints() to retrieve the points to add |
|
234 | + * |
|
235 | + * @return self |
|
236 | + */ |
|
237 | 237 | public function removeWin(string $groupId = ''){ |
238 | 238 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
239 | 239 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getWinPoints(); |
@@ -243,16 +243,16 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Adds a draw points to the team |
|
247 | - * |
|
248 | - * @param string|int|null $groupId An id of group to add the results from |
|
249 | - * |
|
250 | - * @throws \Exception if the group results have not been added |
|
251 | - * |
|
252 | - * @uses Group::getDrawPoints() to retrieve the points to add |
|
253 | - * |
|
254 | - * @return self |
|
255 | - */ |
|
246 | + * Adds a draw points to the team |
|
247 | + * |
|
248 | + * @param string|int|null $groupId An id of group to add the results from |
|
249 | + * |
|
250 | + * @throws \Exception if the group results have not been added |
|
251 | + * |
|
252 | + * @uses Group::getDrawPoints() to retrieve the points to add |
|
253 | + * |
|
254 | + * @return self |
|
255 | + */ |
|
256 | 256 | public function addDraw(string $groupId = ''){ |
257 | 257 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
258 | 258 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getDrawPoints(); |
@@ -261,16 +261,16 @@ discard block |
||
261 | 261 | return $this; |
262 | 262 | } |
263 | 263 | /** |
264 | - * Remove draw points to the team |
|
265 | - * |
|
266 | - * @param string|int|null $groupId An id of group to add the results from |
|
267 | - * |
|
268 | - * @throws \Exception if the group results have not been added |
|
269 | - * |
|
270 | - * @uses Group::getDrawPoints() to retrieve the points to add |
|
271 | - * |
|
272 | - * @return self |
|
273 | - */ |
|
264 | + * Remove draw points to the team |
|
265 | + * |
|
266 | + * @param string|int|null $groupId An id of group to add the results from |
|
267 | + * |
|
268 | + * @throws \Exception if the group results have not been added |
|
269 | + * |
|
270 | + * @uses Group::getDrawPoints() to retrieve the points to add |
|
271 | + * |
|
272 | + * @return self |
|
273 | + */ |
|
274 | 274 | public function removeDraw(string $groupId = ''){ |
275 | 275 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
276 | 276 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
283 | - * Adds a loss points to the team |
|
284 | - * |
|
285 | - * @param string|int|null $groupId An id of group to add the results from |
|
286 | - * |
|
287 | - * @throws \Exception if the group results have not been added |
|
288 | - * |
|
289 | - * @uses Group::getLossPoints() to retrieve the points to add |
|
290 | - * |
|
291 | - * @return self |
|
292 | - */ |
|
283 | + * Adds a loss points to the team |
|
284 | + * |
|
285 | + * @param string|int|null $groupId An id of group to add the results from |
|
286 | + * |
|
287 | + * @throws \Exception if the group results have not been added |
|
288 | + * |
|
289 | + * @uses Group::getLossPoints() to retrieve the points to add |
|
290 | + * |
|
291 | + * @return self |
|
292 | + */ |
|
293 | 293 | public function addLoss(string $groupId = ''){ |
294 | 294 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
295 | 295 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getLostPoints(); |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | return $this; |
299 | 299 | } |
300 | 300 | /** |
301 | - * Remove loss points to the team |
|
302 | - * |
|
303 | - * @param string|int|null $groupId An id of group to add the results from |
|
304 | - * |
|
305 | - * @throws \Exception if the group results have not been added |
|
306 | - * |
|
307 | - * @uses Group::getLossPoints() to retrieve the points to add |
|
308 | - * |
|
309 | - * @return self |
|
310 | - */ |
|
301 | + * Remove loss points to the team |
|
302 | + * |
|
303 | + * @param string|int|null $groupId An id of group to add the results from |
|
304 | + * |
|
305 | + * @throws \Exception if the group results have not been added |
|
306 | + * |
|
307 | + * @uses Group::getLossPoints() to retrieve the points to add |
|
308 | + * |
|
309 | + * @return self |
|
310 | + */ |
|
311 | 311 | public function removeLoss(string $groupId = ''){ |
312 | 312 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
313 | 313 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getLostPoints(); |
@@ -317,16 +317,16 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Adds points for being second to the team |
|
321 | - * |
|
322 | - * @param string|int|null $groupId An id of group to add the results from |
|
323 | - * |
|
324 | - * @throws \Exception if the group results have not been added |
|
325 | - * |
|
326 | - * @uses Group::getSecondPoints() to retrieve the points to add |
|
327 | - * |
|
328 | - * @return self |
|
329 | - */ |
|
320 | + * Adds points for being second to the team |
|
321 | + * |
|
322 | + * @param string|int|null $groupId An id of group to add the results from |
|
323 | + * |
|
324 | + * @throws \Exception if the group results have not been added |
|
325 | + * |
|
326 | + * @uses Group::getSecondPoints() to retrieve the points to add |
|
327 | + * |
|
328 | + * @return self |
|
329 | + */ |
|
330 | 330 | public function addSecond(string $groupId = ''){ |
331 | 331 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
332 | 332 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getSecondPoints(); |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | return $this; |
336 | 336 | } |
337 | 337 | /** |
338 | - * Remove points for being second to the team |
|
339 | - * |
|
340 | - * @param string|int|null $groupId An id of group to add the results from |
|
341 | - * |
|
342 | - * @throws \Exception if the group results have not been added |
|
343 | - * |
|
344 | - * @uses Group::getSecondPoints() to retrieve the points to add |
|
345 | - * |
|
346 | - * @return self |
|
347 | - */ |
|
338 | + * Remove points for being second to the team |
|
339 | + * |
|
340 | + * @param string|int|null $groupId An id of group to add the results from |
|
341 | + * |
|
342 | + * @throws \Exception if the group results have not been added |
|
343 | + * |
|
344 | + * @uses Group::getSecondPoints() to retrieve the points to add |
|
345 | + * |
|
346 | + * @return self |
|
347 | + */ |
|
348 | 348 | public function removeSecond(string $groupId = ''){ |
349 | 349 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
350 | 350 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
@@ -354,16 +354,16 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Adds points for being third to the team |
|
358 | - * |
|
359 | - * @param string|int|null $groupId An id of group to add the results from |
|
360 | - * |
|
361 | - * @throws \Exception if the group results have not been added |
|
362 | - * |
|
363 | - * @uses Group::getThirdPoints() to retrieve the points to add |
|
364 | - * |
|
365 | - * @return self |
|
366 | - */ |
|
357 | + * Adds points for being third to the team |
|
358 | + * |
|
359 | + * @param string|int|null $groupId An id of group to add the results from |
|
360 | + * |
|
361 | + * @throws \Exception if the group results have not been added |
|
362 | + * |
|
363 | + * @uses Group::getThirdPoints() to retrieve the points to add |
|
364 | + * |
|
365 | + * @return self |
|
366 | + */ |
|
367 | 367 | public function addThird(string $groupId = ''){ |
368 | 368 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
369 | 369 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getThirdPoints(); |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | return $this; |
373 | 373 | } |
374 | 374 | /** |
375 | - * Remove points for being third to the team |
|
376 | - * |
|
377 | - * @param string|int|null $groupId An id of group to add the results from |
|
378 | - * |
|
379 | - * @throws \Exception if the group results have not been added |
|
380 | - * |
|
381 | - * @uses Group::getThirdPoints() to retrieve the points to add |
|
382 | - * |
|
383 | - * @return self |
|
384 | - */ |
|
375 | + * Remove points for being third to the team |
|
376 | + * |
|
377 | + * @param string|int|null $groupId An id of group to add the results from |
|
378 | + * |
|
379 | + * @throws \Exception if the group results have not been added |
|
380 | + * |
|
381 | + * @uses Group::getThirdPoints() to retrieve the points to add |
|
382 | + * |
|
383 | + * @return self |
|
384 | + */ |
|
385 | 385 | public function removeThird(string $groupId = ''){ |
386 | 386 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
387 | 387 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Calculate all the points acquired from given group ids |
|
395 | - * |
|
396 | - * @param array $groupIds Array of group ids |
|
397 | - * |
|
398 | - * @return int Sum of the points or sum of all points if argument is empty |
|
399 | - */ |
|
394 | + * Calculate all the points acquired from given group ids |
|
395 | + * |
|
396 | + * @param array $groupIds Array of group ids |
|
397 | + * |
|
398 | + * @return int Sum of the points or sum of all points if argument is empty |
|
399 | + */ |
|
400 | 400 | public function sumPoints(array $groupIds = []) { |
401 | 401 | if (count($groupIds) === 0) return $this->sumPoints; |
402 | 402 | $sum = 0; |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | return $sum; |
407 | 407 | } |
408 | 408 | /** |
409 | - * Calculate all score acquired from given group ids |
|
410 | - * |
|
411 | - * @param array $groupIds Array of group ids |
|
412 | - * |
|
413 | - * @return int Sum of score or sum of all score if argument is empty |
|
414 | - */ |
|
409 | + * Calculate all score acquired from given group ids |
|
410 | + * |
|
411 | + * @param array $groupIds Array of group ids |
|
412 | + * |
|
413 | + * @return int Sum of score or sum of all score if argument is empty |
|
414 | + */ |
|
415 | 415 | public function sumScore(array $groupIds = []) { |
416 | 416 | if (count($groupIds) === 0) return $this->sumScore; |
417 | 417 | $sum = 0; |
@@ -422,45 +422,45 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
425 | - * Adds score to the total sum |
|
426 | - * |
|
427 | - * @param int $score Score to add |
|
428 | - * |
|
429 | - * @return self |
|
430 | - */ |
|
425 | + * Adds score to the total sum |
|
426 | + * |
|
427 | + * @param int $score Score to add |
|
428 | + * |
|
429 | + * @return self |
|
430 | + */ |
|
431 | 431 | public function addScore(int $score) { |
432 | 432 | $this->sumScore += $score; |
433 | 433 | return $this; |
434 | 434 | } |
435 | 435 | /** |
436 | - * Removes score to the total sum |
|
437 | - * |
|
438 | - * @param int $score Score to add |
|
439 | - * |
|
440 | - * @return self |
|
441 | - */ |
|
436 | + * Removes score to the total sum |
|
437 | + * |
|
438 | + * @param int $score Score to add |
|
439 | + * |
|
440 | + * @return self |
|
441 | + */ |
|
442 | 442 | public function removeScore(int $score) { |
443 | 443 | $this->sumScore -= $score; |
444 | 444 | return $this; |
445 | 445 | } |
446 | 446 | /** |
447 | - * Adds points to the total sum |
|
448 | - * |
|
449 | - * @param int $points Points to add |
|
450 | - * |
|
451 | - * @return self |
|
452 | - */ |
|
447 | + * Adds points to the total sum |
|
448 | + * |
|
449 | + * @param int $points Points to add |
|
450 | + * |
|
451 | + * @return self |
|
452 | + */ |
|
453 | 453 | public function addPoints(int $points) { |
454 | 454 | $this->sumPoints += $points; |
455 | 455 | return $this; |
456 | 456 | } |
457 | 457 | /** |
458 | - * Removes points to the total sum |
|
459 | - * |
|
460 | - * @param int $points Points to remove |
|
461 | - * |
|
462 | - * @return self |
|
463 | - */ |
|
458 | + * Removes points to the total sum |
|
459 | + * |
|
460 | + * @param int $points Points to remove |
|
461 | + * |
|
462 | + * @return self |
|
463 | + */ |
|
464 | 464 | public function removePoints(int $points) { |
465 | 465 | $this->sumPoints -= $points; |
466 | 466 | return $this; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return self |
218 | 218 | */ |
219 | - public function addWin(string $groupId = ''){ |
|
219 | + public function addWin(string $groupId = '') { |
|
220 | 220 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
221 | 221 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getWinPoints(); |
222 | 222 | $this->sumPoints += $this->groupResults[$groupId]['group']->getWinPoints(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return self |
236 | 236 | */ |
237 | - public function removeWin(string $groupId = ''){ |
|
237 | + public function removeWin(string $groupId = '') { |
|
238 | 238 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
239 | 239 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getWinPoints(); |
240 | 240 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getWinPoints(); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return self |
255 | 255 | */ |
256 | - public function addDraw(string $groupId = ''){ |
|
256 | + public function addDraw(string $groupId = '') { |
|
257 | 257 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
258 | 258 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getDrawPoints(); |
259 | 259 | $this->sumPoints += $this->groupResults[$groupId]['group']->getDrawPoints(); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return self |
273 | 273 | */ |
274 | - public function removeDraw(string $groupId = ''){ |
|
274 | + public function removeDraw(string $groupId = '') { |
|
275 | 275 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
276 | 276 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
277 | 277 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getDrawPoints(); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return self |
292 | 292 | */ |
293 | - public function addLoss(string $groupId = ''){ |
|
293 | + public function addLoss(string $groupId = '') { |
|
294 | 294 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
295 | 295 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getLostPoints(); |
296 | 296 | $this->sumPoints += $this->groupResults[$groupId]['group']->getLostPoints(); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return self |
310 | 310 | */ |
311 | - public function removeLoss(string $groupId = ''){ |
|
311 | + public function removeLoss(string $groupId = '') { |
|
312 | 312 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
313 | 313 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getLostPoints(); |
314 | 314 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getLostPoints(); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return self |
329 | 329 | */ |
330 | - public function addSecond(string $groupId = ''){ |
|
330 | + public function addSecond(string $groupId = '') { |
|
331 | 331 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
332 | 332 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getSecondPoints(); |
333 | 333 | $this->sumPoints += $this->groupResults[$groupId]['group']->getSecondPoints(); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return self |
347 | 347 | */ |
348 | - public function removeSecond(string $groupId = ''){ |
|
348 | + public function removeSecond(string $groupId = '') { |
|
349 | 349 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
350 | 350 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
351 | 351 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getSecondPoints(); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return self |
366 | 366 | */ |
367 | - public function addThird(string $groupId = ''){ |
|
367 | + public function addThird(string $groupId = '') { |
|
368 | 368 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
369 | 369 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->getThirdPoints(); |
370 | 370 | $this->sumPoints += $this->groupResults[$groupId]['group']->getThirdPoints(); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return self |
384 | 384 | */ |
385 | - public function removeThird(string $groupId = ''){ |
|
385 | + public function removeThird(string $groupId = '') { |
|
386 | 386 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
387 | 387 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
388 | 388 | $this->sumPoints -= $this->groupResults[$groupId]['group']->getThirdPoints(); |
@@ -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; |