Completed
Push — master ( bf2039...b9aa7a )
by Tomáš
02:10
created
src/classes/class_group.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 		return 'Group '.$this->name;
58 58
 	}
59 59
 
60
-	public function allowSkip(){
60
+	public function allowSkip() {
61 61
 		$this->generator->allowSkip();
62 62
 		return $this;
63 63
 	}
64
-	public function disallowSkip(){
64
+	public function disallowSkip() {
65 65
 		$this->generator->disallowSkip();
66 66
 		return $this;
67 67
 	}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 	public function addTeam(...$teams) {
77 77
 		foreach ($teams as $team) {
78
-			if ($team instanceof Team)  {
78
+			if ($team instanceof Team) {
79 79
 				$this->teams[] = $team;
80 80
 				$team->groupResults[$this->id] = [
81 81
 					'group' => $this,
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 					if ($a->groupResults[$this->id]["points"] === $b->groupResults[$this->id]["points"]) return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1);
170 170
 					return ($a->groupResults[$this->id]["points"] > $b->groupResults[$this->id]["points"] ? -1 : 1);
171 171
 				});
172
-				break;}
172
+				break; }
173 173
 			case \SCORE:{
174 174
 				usort($this->teams, function($a, $b) {
175 175
 					if ($a->groupResults[$this->id]["score"] === $b->groupResults[$this->id]["score"]) return 0;
176 176
 					return ($a->groupResults[$this->id]["score"] > $b->groupResults[$this->id]["score"] ? -1 : 1);
177 177
 				});
178
-				break;}
178
+				break; }
179 179
 		}
180 180
 		return $this->getTeams($filters);
181 181
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		$this->games[] = $g;
307 307
 		return $g;
308 308
 	}
309
-	public function addGame(...$games){
309
+	public function addGame(...$games) {
310 310
 		foreach ($games as $key => $game) {
311 311
 			if (gettype($game) === 'array') {
312 312
 				unset($games[$key]);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		}
351 351
 		return $this;
352 352
 	}
353
-	public function isPlayed(){
353
+	public function isPlayed() {
354 354
 		foreach ($this->games as $game) {
355 355
 			if ((isset($game) || !$this->getSkip()) && !$game->isPlayed()) return false;
356 356
 		}
Please login to merge, or discard this patch.
src/classes/class_generator.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 		$this->group = $group;
19 19
 	}
20 20
 
21
-	public function allowSkip(){
21
+	public function allowSkip() {
22 22
 		$this->allowSkip = true;
23 23
 		return $this;
24 24
 	}
25
-	public function disallowSkip(){
25
+	public function disallowSkip() {
26 26
 		$this->allowSkip = false;
27 27
 		return $this;
28 28
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public function setInGame(int $inGame) {
48
-		if ($inGame < 2 ||  $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
48
+		if ($inGame < 2 || $inGame > 4) throw new \Exception('Expected 2,3 or 4 as inGame '.$inGame.' given');
49 49
 		$this->inGame = $inGame;
50 50
 		return $this;
51 51
 	}
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		switch ($this->type) {
67 67
 			case \R_R:{
68 68
 					$this->group->addGame($this->r_rGames());
69
-				break;}
69
+				break; }
70 70
 			case \TWO_TWO:
71 71
 				$teams = $this->group->getTeams();
72 72
 				$discard = [];
73 73
 				shuffle($teams);
74 74
 				$count = count($teams);
75
-				while (count($teams) % $this->inGame !== 0) { $discard[] = array_shift($teams); }
75
+				while (count($teams)%$this->inGame !== 0) { $discard[] = array_shift($teams); }
76 76
 
77 77
 				while (count($teams) > 0) {
78 78
 					$tInGame = [];
79
-					for ($i=0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
79
+					for ($i = 0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
80 80
 					$this->group->game($tInGame);
81 81
 				}
82 82
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 					}
123 123
 					$games = array_merge($games, $gamesTemp);
124 124
 				}
125
-				break;}
125
+				break; }
126 126
 			case 4:{
127 127
 				$teamsB = $teams;
128 128
 				$lockedTeam1 = array_shift($teamsB);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 					$lockedTeam1 = array_shift($teamsB);
140 140
 				}
141 141
 				$games[] = new \TournamentGenerator\Game(array_merge([$lockedTeam1], $teamsB), $this->group);
142
-				break;}
142
+				break; }
143 143
 		}
144 144
 		return $games;
145 145
 	}
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 	public static function circle_genGames2(array $teams = [], \tournamentGenerator\Group $group) {
155 155
 		$bracket = []; // ARRAY OF GAMES
156 156
 
157
-		if (count($teams) % 2 != 0) $teams[] = \DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
157
+		if (count($teams)%2 != 0) $teams[] = \DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
158 158
 
159 159
 		shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS
160 160
 
161
-		for ($i=0; $i < count($teams)-1; $i++) {
161
+		for ($i = 0; $i < count($teams)-1; $i++) {
162 162
 			$bracket = array_merge($bracket, Generator::circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND
163 163
 
164 164
 			$teams = Generator::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$bracket = [];
174 174
 
175
-		for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
175
+		for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
176 176
 
177 177
 			$home = $teams[$i];
178 178
 			$reverse = array_reverse($teams);
Please login to merge, or discard this patch.
src/classes/class_round.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		return $this->name;
24 24
 	}
25 25
 
26
-	public function addGroup(Group ...$groups){
26
+	public function addGroup(Group ...$groups) {
27 27
 		foreach ($groups as $group) {
28 28
 			if ($group instanceof Group) $this->groups[] = $group;
29 29
 			else throw new \Exception('Trying to add group which is not an instance of Group class.');
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		$this->groups[] = $g->setSkip($this->allowSkip);
36 36
 		return $g;
37 37
 	}
38
-	public function getGroups(){
38
+	public function getGroups() {
39 39
 		$this->orderGroups();
40 40
 		return $this->groups;
41 41
 	}
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 		return array_map(function($a) { return $a->id; }, $this->groups);
45 45
 	}
46 46
 	public function orderGroups() {
47
-		usort($this->groups, function($a, $b){
48
-			return $a->order - $b->order;
47
+		usort($this->groups, function($a, $b) {
48
+			return $a->order-$b->order;
49 49
 		});
50 50
 	}
51 51
 
52
-	public function allowSkip(){
52
+	public function allowSkip() {
53 53
 		$this->allowSkip = true;
54 54
 		return $this;
55 55
 	}
56
-	public function disallowSkip(){
56
+	public function disallowSkip() {
57 57
 		$this->allowSkip = false;
58 58
 		return $this;
59 59
 	}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		return $this->allowSkip;
66 66
 	}
67 67
 
68
-	public function genGames(){
68
+	public function genGames() {
69 69
 		foreach ($this->groups as $group) {
70 70
 			$group->genGames();
71 71
 			$this->games = array_merge($this->games, $group->orderGames());
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	public function getGames() {
76 76
 		return $this->games;
77 77
 	}
78
-	public function isPlayed(){
78
+	public function isPlayed() {
79 79
 		foreach ($this->groups as $group) {
80 80
 			if (!$group->isPlayed()) return false;
81 81
 		}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	public function addTeam(...$teams) {
86 86
 		foreach ($teams as $team) {
87
-			if ($team instanceof Team)  {
87
+			if ($team instanceof Team) {
88 88
 				$this->teams[] = $team;
89 89
 			}
90 90
 			elseif (gettype($team) === 'array') {
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 					if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1);
134 134
 					return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1);
135 135
 				});
136
-				break;}
136
+				break; }
137 137
 			case \SCORE:{
138 138
 				uasort($this->teams, function($a, $b) use ($groupsIds) {
139 139
 					if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0;
140 140
 					return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1);
141 141
 				});
142
-				break;}
142
+				break; }
143 143
 		}
144 144
 		return $this->teams;
145 145
 	}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		return $this;
169 169
 	}
170 170
 
171
-	public function progress(bool $blank = false){
171
+	public function progress(bool $blank = false) {
172 172
 		foreach ($this->groups as $group) {
173 173
 			$group->progress($blank);
174 174
 		}
Please login to merge, or discard this patch.