@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | return 'Group '.$this->name; |
| 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 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | public function addTeam(...$teams) { |
| 88 | 88 | foreach ($teams as $team) { |
| 89 | - if ($team instanceof Team) { |
|
| 89 | + if ($team instanceof Team) { |
|
| 90 | 90 | $this->teams[] = $team; |
| 91 | 91 | $team->groupResults[$this->id] = [ |
| 92 | 92 | 'group' => $this, |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"]) return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1); |
| 244 | 244 | return ($a->groupResults[$this->id]["points"] > $b->groupResults[$this->id]["points"] ? -1 : 1); |
| 245 | 245 | }); |
| 246 | - break;} |
|
| 246 | + break; } |
|
| 247 | 247 | case SCORE:{ |
| 248 | 248 | usort($this->teams, function($a, $b) { |
| 249 | 249 | if ($a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) return 0; |
| 250 | 250 | return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1); |
| 251 | 251 | }); |
| 252 | - break;} |
|
| 252 | + break; } |
|
| 253 | 253 | } |
| 254 | 254 | return $this->getTeams($filters); |
| 255 | 255 | } |
@@ -314,19 +314,19 @@ discard block |
||
| 314 | 314 | switch ($this->type) { |
| 315 | 315 | case R_R:{ |
| 316 | 316 | $this->games = $this->r_rGames(); |
| 317 | - break;} |
|
| 317 | + break; } |
|
| 318 | 318 | case TWO_TWO: |
| 319 | 319 | $teams = $this->teams; |
| 320 | 320 | $discard = []; |
| 321 | 321 | shuffle($teams); |
| 322 | 322 | $count = count($teams); |
| 323 | - while (count($teams) % $this->inGame !== 0) { |
|
| 323 | + while (count($teams)%$this->inGame !== 0) { |
|
| 324 | 324 | $discard[] = array_shift($teams); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | while (count($teams) > 0) { |
| 328 | 328 | $tInGame = []; |
| 329 | - for ($i=0; $i < $this->inGame; $i++) { |
|
| 329 | + for ($i = 0; $i < $this->inGame; $i++) { |
|
| 330 | 330 | $tInGame[] = array_shift($teams); |
| 331 | 331 | } |
| 332 | 332 | $this->game($tInGame); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $this->games[] = $g; |
| 366 | 366 | return $g; |
| 367 | 367 | } |
| 368 | - public function addGame(Game ...$games){ |
|
| 368 | + public function addGame(Game ...$games) { |
|
| 369 | 369 | foreach ($games as $game) { |
| 370 | 370 | if ($game instanceof Game) $this->games[] = $game; |
| 371 | 371 | else throw new \Exception('Trying to add game which is not instance of Game object.'); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | foreach ($games as $key => $game) { |
| 462 | 462 | $gTeams = $game->getTeamsIds(); |
| 463 | 463 | $suitable = true; |
| 464 | - $requiredTeams = array_filter($teams, function($a){ |
|
| 464 | + $requiredTeams = array_filter($teams, function($a) { |
|
| 465 | 465 | return $a < 4; |
| 466 | 466 | }); |
| 467 | 467 | foreach ($gTeams as $tid) { |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | foreach ($games as $key => $game) { |
| 513 | 513 | $gTeams = $game->getTeamsIds(); |
| 514 | 514 | $suitable = false; |
| 515 | - $requiredTeams = array_filter($teams, function($a){ |
|
| 515 | + $requiredTeams = array_filter($teams, function($a) { |
|
| 516 | 516 | return $a < 4; |
| 517 | 517 | }); |
| 518 | 518 | foreach ($gTeams as $tid) { |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $games = array_merge($games, $games); |
| 558 | 558 | } |
| 559 | 559 | // $this->orderGames(); |
| 560 | - break;} |
|
| 560 | + break; } |
|
| 561 | 561 | case 4:{ |
| 562 | 562 | $teamsB = $teams; |
| 563 | 563 | $lockedTeam1 = array_shift($teamsB); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | $games[] = new Game(array_merge([$lockedTeam1], $teamsB), $this); |
| 577 | 577 | // $this->orderGames(); |
| 578 | - break;} |
|
| 578 | + break; } |
|
| 579 | 579 | } |
| 580 | 580 | return $games; |
| 581 | 581 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | return $this; |
| 603 | 603 | } |
| 604 | - public function isPlayed(){ |
|
| 604 | + public function isPlayed() { |
|
| 605 | 605 | foreach ($this->games as $game) { |
| 606 | 606 | if ((isset($game) || !$this->getSkip()) && !$game->isPlayed()) return false; |
| 607 | 607 | } |
@@ -43,61 +43,61 @@ |
||
| 43 | 43 | return array_filter($this->groupResults[$groupId], function($k) { return $k !== 'group'; }, ARRAY_FILTER_USE_KEY); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function addWin(string $groupId = ''){ |
|
| 46 | + public function addWin(string $groupId = '') { |
|
| 47 | 47 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 48 | 48 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints; |
| 49 | 49 | $this->groupResults[$groupId]['wins']++; |
| 50 | 50 | return $this; |
| 51 | 51 | } |
| 52 | - public function removeWin(string $groupId = ''){ |
|
| 52 | + public function removeWin(string $groupId = '') { |
|
| 53 | 53 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 54 | 54 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->winPoints; |
| 55 | 55 | $this->groupResults[$groupId]['wins']--; |
| 56 | 56 | return $this; |
| 57 | 57 | } |
| 58 | - public function addDraw(string $groupId = ''){ |
|
| 58 | + public function addDraw(string $groupId = '') { |
|
| 59 | 59 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 60 | 60 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->drawPoints; |
| 61 | 61 | $this->groupResults[$groupId]['draws']++; |
| 62 | 62 | return $this; |
| 63 | 63 | } |
| 64 | - public function removeDraw(string $groupId = ''){ |
|
| 64 | + public function removeDraw(string $groupId = '') { |
|
| 65 | 65 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 66 | 66 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->drawPointsPoints; |
| 67 | 67 | $this->groupResults[$groupId]['draws']--; |
| 68 | 68 | return $this; |
| 69 | 69 | } |
| 70 | - public function addLoss(string $groupId = ''){ |
|
| 70 | + public function addLoss(string $groupId = '') { |
|
| 71 | 71 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 72 | 72 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->lostPoints; |
| 73 | 73 | $this->groupResults[$groupId]['losses']++; |
| 74 | 74 | return $this; |
| 75 | 75 | } |
| 76 | - public function removeLoss(string $groupId = ''){ |
|
| 76 | + public function removeLoss(string $groupId = '') { |
|
| 77 | 77 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 78 | 78 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->lostPoints; |
| 79 | 79 | $this->groupResults[$groupId]['losses']--; |
| 80 | 80 | return $this; |
| 81 | 81 | } |
| 82 | - public function addSecond(string $groupId = ''){ |
|
| 82 | + public function addSecond(string $groupId = '') { |
|
| 83 | 83 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 84 | 84 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->secondPoints; |
| 85 | 85 | $this->groupResults[$groupId]['second']++; |
| 86 | 86 | return $this; |
| 87 | 87 | } |
| 88 | - public function removeSecond(string $groupId = ''){ |
|
| 88 | + public function removeSecond(string $groupId = '') { |
|
| 89 | 89 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 90 | 90 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->secondPoints; |
| 91 | 91 | $this->groupResults[$groupId]['second']--; |
| 92 | 92 | return $this; |
| 93 | 93 | } |
| 94 | - public function addThird(string $groupId = ''){ |
|
| 94 | + public function addThird(string $groupId = '') { |
|
| 95 | 95 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 96 | 96 | $this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->thirdPoints; |
| 97 | 97 | $this->groupResults[$groupId]['third']++; |
| 98 | 98 | return $this; |
| 99 | 99 | } |
| 100 | - public function removeThird(string $groupId = ''){ |
|
| 100 | + public function removeThird(string $groupId = '') { |
|
| 101 | 101 | if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')'); |
| 102 | 102 | $this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->thirdPoints; |
| 103 | 103 | $this->groupResults[$groupId]['third']--; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return $this->name; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function addGroup(Group ...$groups){ |
|
| 28 | + public function addGroup(Group ...$groups) { |
|
| 29 | 29 | foreach ($groups as $group) { |
| 30 | 30 | if ($group instanceof Group) $this->groups[] = $group; |
| 31 | 31 | else throw new \Exception('Trying to add group which is not an instance of Group class.'); |
@@ -37,21 +37,21 @@ discard block |
||
| 37 | 37 | $this->groups[] = $g->setSkip($this->allowSkip); |
| 38 | 38 | return $g; |
| 39 | 39 | } |
| 40 | - public function getGroups(){ |
|
| 40 | + public function getGroups() { |
|
| 41 | 41 | $this->orderGroups(); |
| 42 | 42 | return $this->groups; |
| 43 | 43 | } |
| 44 | 44 | public function orderGroups() { |
| 45 | - usort($this->groups, function($a, $b){ |
|
| 46 | - return $a->order - $b->order; |
|
| 45 | + usort($this->groups, function($a, $b) { |
|
| 46 | + return $a->order-$b->order; |
|
| 47 | 47 | }); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function allowSkip(){ |
|
| 50 | + public function allowSkip() { |
|
| 51 | 51 | $this->allowSkip = true; |
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | - public function disallowSkip(){ |
|
| 54 | + public function disallowSkip() { |
|
| 55 | 55 | $this->allowSkip = false; |
| 56 | 56 | return $this; |
| 57 | 57 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return $this->allowSkip; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function genGames(){ |
|
| 66 | + public function genGames() { |
|
| 67 | 67 | $games = []; |
| 68 | 68 | $g = 0; |
| 69 | 69 | foreach ($this->groups as $group) { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function getGames() { |
| 88 | 88 | return $this->games; |
| 89 | 89 | } |
| 90 | - public function isPlayed(){ |
|
| 90 | + public function isPlayed() { |
|
| 91 | 91 | foreach ($this->groups as $group) { |
| 92 | 92 | if (!$group->isPlayed()) return false; |
| 93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function addTeam(...$teams) { |
| 98 | 98 | foreach ($teams as $team) { |
| 99 | - if ($team instanceof Team) { |
|
| 99 | + if ($team instanceof Team) { |
|
| 100 | 100 | $this->teams[] = $team; |
| 101 | 101 | } |
| 102 | 102 | elseif (gettype($team) === 'array') { |
@@ -157,14 +157,14 @@ discard block |
||
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function progress(){ |
|
| 160 | + public function progress() { |
|
| 161 | 161 | foreach ($this->groups as $group) { |
| 162 | 162 | $group->progress(); |
| 163 | 163 | } |
| 164 | 164 | return $this; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function progressBlank(){ |
|
| 167 | + public function progressBlank() { |
|
| 168 | 168 | if (!$this->isPlayed()) $this->simulate(); |
| 169 | 169 | foreach ($this->groups as $group) { |
| 170 | 170 | $group->progressBlank(); |
@@ -45,12 +45,12 @@ |
||
| 45 | 45 | |
| 46 | 46 | private $groups = []; |
| 47 | 47 | |
| 48 | - function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []){ |
|
| 48 | + function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []) { |
|
| 49 | 49 | if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) $this->what = strtolower($what); |
| 50 | 50 | if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) $this->how = $how; |
| 51 | 51 | if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) $this->val = $val; |
| 52 | 52 | foreach ($groups as $group) { |
| 53 | - if ($group instanceof Group) $this->groups[] = $group->id; |
|
| 53 | + if ($group instanceof Group) $this->groups[] = $group->id; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | public function __toString() { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | private $allowSkip = false; |
| 24 | 24 | |
| 25 | - function __construct(string $name = ''){ |
|
| 25 | + function __construct(string $name = '') { |
|
| 26 | 26 | $this->name = $name; |
| 27 | 27 | } |
| 28 | 28 | public function __toString() { |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | public function getCategoryWait() { |
| 58 | 58 | return $this->expectedCategoryWait; |
| 59 | 59 | } |
| 60 | - public function getTournamentTime(){ |
|
| 60 | + public function getTournamentTime() { |
|
| 61 | 61 | $games = count($this->getGames()); |
| 62 | 62 | return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function allowSkip(){ |
|
| 65 | + public function allowSkip() { |
|
| 66 | 66 | $this->allowSkip = true; |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | - public function disallowSkip(){ |
|
| 69 | + public function disallowSkip() { |
|
| 70 | 70 | $this->allowSkip = false; |
| 71 | 71 | return $this; |
| 72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return $this->allowSkip; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function addCategory(Category ...$categories){ |
|
| 81 | + public function addCategory(Category ...$categories) { |
|
| 82 | 82 | foreach ($categories as $category) { |
| 83 | 83 | if ($category instanceof Category) $this->categories[] = $category; |
| 84 | 84 | else throw new \Exception('Trying to add category which is not an instance of the Category class.'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | public function addTeam(...$teams) { |
| 121 | 121 | foreach ($teams as $team) { |
| 122 | - if ($team instanceof Team) { |
|
| 122 | + if ($team instanceof Team) { |
|
| 123 | 123 | $this->teams[] = $team; |
| 124 | 124 | } |
| 125 | 125 | elseif (gettype($team) === 'array') { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $this->name = $name; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function addRound(Round ...$rounds){ |
|
| 24 | + public function addRound(Round ...$rounds) { |
|
| 25 | 25 | foreach ($rounds as $round) { |
| 26 | 26 | if ($round instanceof Round) $this->rounds[] = $round; |
| 27 | 27 | else throw new \Exception('Trying to add round which is not an instance of Round class.'); |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | $this->rounds[] = $r->setSkip($this->allowSkip); |
| 34 | 34 | return $r; |
| 35 | 35 | } |
| 36 | - public function getRounds(){ |
|
| 36 | + public function getRounds() { |
|
| 37 | 37 | return $this->rounds; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function allowSkip(){ |
|
| 40 | + public function allowSkip() { |
|
| 41 | 41 | $this->allowSkip = true; |
| 42 | 42 | return $this; |
| 43 | 43 | } |
| 44 | - public function disallowSkip(){ |
|
| 44 | + public function disallowSkip() { |
|
| 45 | 45 | $this->allowSkip = false; |
| 46 | 46 | return $this; |
| 47 | 47 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function addTeam(...$teams) { |
| 57 | 57 | foreach ($teams as $team) { |
| 58 | - if ($team instanceof Team) { |
|
| 58 | + if ($team instanceof Team) { |
|
| 59 | 59 | $this->teams[] = $team; |
| 60 | 60 | } |
| 61 | 61 | elseif (gettype($team) === 'array') { |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | 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)); |
| 79 | 79 | return $this; |
| 80 | 80 | } |
| 81 | - public function getTeams(){ |
|
| 81 | + public function getTeams() { |
|
| 82 | 82 | return $this->teams; |
| 83 | 83 | } |
| 84 | - public function getTeamsIds(){ |
|
| 84 | + public function getTeamsIds() { |
|
| 85 | 85 | $ids = []; |
| 86 | 86 | foreach ($this->teams as $team) { |
| 87 | 87 | $ids[] = $team->id; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $team->addLoss($this->group->id); |
| 129 | 129 | $this->results[$team->id] += ['points' => $this->group->lostPoints, 'type' => 'loss']; |
| 130 | 130 | } |
| 131 | - break;} |
|
| 131 | + break; } |
|
| 132 | 132 | case 3:{ |
| 133 | 133 | switch ($i) { |
| 134 | 134 | case 1: |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $this->results[$team->id] += ['points' => $this->group->lostPoints, 'type' => 'loss']; |
| 148 | 148 | break; |
| 149 | 149 | } |
| 150 | - break;} |
|
| 150 | + break; } |
|
| 151 | 151 | case 4:{ |
| 152 | 152 | switch ($i) { |
| 153 | 153 | case 1: |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $this->results[$team->id] += ['points' => $this->group->lostPoints, 'type' => 'loss']; |
| 172 | 172 | break; |
| 173 | 173 | } |
| 174 | - break;} |
|
| 174 | + break; } |
|
| 175 | 175 | } |
| 176 | 176 | $team->groupResults[$this->group->id]['score'] += $score; |
| 177 | 177 | $i++; |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | return $this; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function progressBlank(){ |
|
| 48 | + public function progressBlank() { |
|
| 49 | 49 | $teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters); |
| 50 | 50 | if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
| 51 | 51 | else $next = $teams; |