@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->setId(isset($id) ? $id : uniqid()); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function addGroup(Group ...$groups){ |
|
| 21 | + public function addGroup(Group ...$groups) { |
|
| 22 | 22 | foreach ($groups as $group) { |
| 23 | 23 | $this->groups[] = $group; |
| 24 | 24 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $this->groups[] = $g->setSkip($this->allowSkip); |
| 30 | 30 | return $g; |
| 31 | 31 | } |
| 32 | - public function getGroups(){ |
|
| 32 | + public function getGroups() { |
|
| 33 | 33 | $this->orderGroups(); |
| 34 | 34 | return $this->groups; |
| 35 | 35 | } |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | return array_map(function($a) { return $a->getId(); }, $this->groups); |
| 39 | 39 | } |
| 40 | 40 | public function orderGroups() { |
| 41 | - usort($this->groups, function($a, $b){ |
|
| 42 | - return $a->getOrder() - $b->getOrder(); |
|
| 41 | + usort($this->groups, function($a, $b) { |
|
| 42 | + return $a->getOrder()-$b->getOrder(); |
|
| 43 | 43 | }); |
| 44 | 44 | return $this->groups; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function allowSkip(){ |
|
| 47 | + public function allowSkip() { |
|
| 48 | 48 | $this->allowSkip = true; |
| 49 | 49 | return $this; |
| 50 | 50 | } |
| 51 | - public function disallowSkip(){ |
|
| 51 | + public function disallowSkip() { |
|
| 52 | 52 | $this->allowSkip = false; |
| 53 | 53 | return $this; |
| 54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return $this->allowSkip; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function genGames(){ |
|
| 63 | + public function genGames() { |
|
| 64 | 64 | foreach ($this->groups as $group) { |
| 65 | 65 | $group->genGames(); |
| 66 | 66 | $this->games = array_merge($this->games, $group->orderGames()); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function getGames() { |
| 71 | 71 | return $this->games; |
| 72 | 72 | } |
| 73 | - public function isPlayed(){ |
|
| 73 | + public function isPlayed() { |
|
| 74 | 74 | if (count($this->games) === 0) return false; |
| 75 | 75 | foreach ($this->groups as $group) { |
| 76 | 76 | if (!$group->isPlayed()) return false; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function progress(bool $blank = false){ |
|
| 125 | + public function progress(bool $blank = false) { |
|
| 126 | 126 | foreach ($this->groups as $group) { |
| 127 | 127 | $group->progress($blank); |
| 128 | 128 | } |
@@ -43,14 +43,14 @@ |
||
| 43 | 43 | |
| 44 | 44 | private $groups = []; |
| 45 | 45 | |
| 46 | - function __construct(string $what = 'points', string $how = '>', $val = 0, array $groups = []){ |
|
| 46 | + function __construct(string $what = 'points', string $how = '>', $val = 0, array $groups = []) { |
|
| 47 | 47 | if (!in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) throw new \Exception('Trying to filter unexisting type ('.$what.')'); |
| 48 | 48 | $this->what = strtolower($what); |
| 49 | 49 | if (!in_array($how, ['>', '<', '>=', '<=', '=', '!='])) throw new \Exception('Trying to filter with unexisting operator ('.$how.')'); |
| 50 | 50 | $this->how = $how; |
| 51 | 51 | if (!(gettype($val) === 'integer' && strtolower($what) !== 'team') && !($val instanceof Team && strtolower($what) === 'team')) throw new \Exception('Unsupported filter value type ('.gettype($val).')'); |
| 52 | 52 | $this->val = $val; |
| 53 | - $this->groups = array_map(function($a) { return $a->getId(); }, array_filter($groups, function($a) {return ($a instanceof Group);})); |
|
| 53 | + $this->groups = array_map(function($a) { return $a->getId(); }, array_filter($groups, function($a) {return ($a instanceof Group); })); |
|
| 54 | 54 | } |
| 55 | 55 | public function __toString() { |
| 56 | 56 | return 'Filter: '.$this->what.' '.($this->what !== 'notprogressed' && $this->what !== 'progressed' ? $this->how.' '.$this->val : ''); |
@@ -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 | } |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | public function addProgressed(...$teams) { |
| 142 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($teams, function($a){return $a instanceof Team;}))); |
|
| 143 | - foreach (array_filter($teams, function($a){return is_array($a);}) as $team) { |
|
| 144 | - $this->progressed = array_merge($this->progressed, array_map(function ($a) {return $a->getId();}, array_filter($team, function($a) { |
|
| 142 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($teams, function($a) {return $a instanceof Team; }))); |
|
| 143 | + foreach (array_filter($teams, function($a) {return is_array($a); }) as $team) { |
|
| 144 | + $this->progressed = array_merge($this->progressed, array_map(function($a) {return $a->getId(); }, array_filter($team, function($a) { |
|
| 145 | 145 | return ($a instanceof Team); |
| 146 | 146 | }))); |
| 147 | 147 | } |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | $this->games[] = $g; |
| 162 | 162 | return $g; |
| 163 | 163 | } |
| 164 | - public function addGame(...$games){ |
|
| 165 | - $this->games = array_merge($this->games, array_filter($games, function($a){ return ($a instanceof Game); })); |
|
| 164 | + public function addGame(...$games) { |
|
| 165 | + $this->games = array_merge($this->games, array_filter($games, function($a) { return ($a instanceof Game); })); |
|
| 166 | 166 | |
| 167 | - foreach (array_filter($games, function($a){return is_array($a);}) as $key => $game) { |
|
| 168 | - $this->games = array_merge($this->games, array_filter($game, function($a){ return ($a instanceof Game); })); |
|
| 167 | + foreach (array_filter($games, function($a) {return is_array($a); }) as $key => $game) { |
|
| 168 | + $this->games = array_merge($this->games, array_filter($game, function($a) { return ($a instanceof Game); })); |
|
| 169 | 169 | } |
| 170 | 170 | return $this; |
| 171 | 171 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | - public function isPlayed(){ |
|
| 190 | + public function isPlayed() { |
|
| 191 | 191 | if (count($this->games) === 0) return false; |
| 192 | 192 | foreach ($this->games as $game) { |
| 193 | 193 | if (!$game->isPlayed()) return false; |