Completed
Push — master ( 5d9f44...4b85e8 )
by Tomáš
03:31
created
src/TournamentGenerator/Team.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,70 +66,70 @@
 block discarded – undo
66 66
 		return $this->sumScore;
67 67
 	}
68 68
 
69
-	public function addWin(string $groupId = ''){
69
+	public function addWin(string $groupId = '') {
70 70
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
71 71
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints;
72 72
 		$this->sumPoints += $this->groupResults[$groupId]['group']->winPoints;
73 73
 		$this->groupResults[$groupId]['wins']++;
74 74
 		return $this;
75 75
 	}
76
-	public function removeWin(string $groupId = ''){
76
+	public function removeWin(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']->winPoints;
79 79
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->winPoints;
80 80
 		$this->groupResults[$groupId]['wins']--;
81 81
 		return $this;
82 82
 	}
83
-	public function addDraw(string $groupId = ''){
83
+	public function addDraw(string $groupId = '') {
84 84
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
85 85
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->drawPoints;
86 86
 		$this->sumPoints += $this->groupResults[$groupId]['group']->drawPoints;
87 87
 		$this->groupResults[$groupId]['draws']++;
88 88
 		return $this;
89 89
 	}
90
-	public function removeDraw(string $groupId = ''){
90
+	public function removeDraw(string $groupId = '') {
91 91
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
92 92
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->drawPointsPoints;
93 93
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->drawPoints;
94 94
 		$this->groupResults[$groupId]['draws']--;
95 95
 		return $this;
96 96
 	}
97
-	public function addLoss(string $groupId = ''){
97
+	public function addLoss(string $groupId = '') {
98 98
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
99 99
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->lostPoints;
100 100
 		$this->sumPoints += $this->groupResults[$groupId]['group']->lostPoints;
101 101
 		$this->groupResults[$groupId]['losses']++;
102 102
 		return $this;
103 103
 	}
104
-	public function removeLoss(string $groupId = ''){
104
+	public function removeLoss(string $groupId = '') {
105 105
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
106 106
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->lostPoints;
107 107
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->lostPoints;
108 108
 		$this->groupResults[$groupId]['losses']--;
109 109
 		return $this;
110 110
 	}
111
-	public function addSecond(string $groupId = ''){
111
+	public function addSecond(string $groupId = '') {
112 112
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
113 113
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->secondPoints;
114 114
 		$this->sumPoints += $this->groupResults[$groupId]['group']->secondPoints;
115 115
 		$this->groupResults[$groupId]['second']++;
116 116
 		return $this;
117 117
 	}
118
-	public function removeSecond(string $groupId = ''){
118
+	public function removeSecond(string $groupId = '') {
119 119
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
120 120
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->secondPoints;
121 121
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->secondPoints;
122 122
 		$this->groupResults[$groupId]['second']--;
123 123
 		return $this;
124 124
 	}
125
-	public function addThird(string $groupId = ''){
125
+	public function addThird(string $groupId = '') {
126 126
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
127 127
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->thirdPoints;
128 128
 		$this->sumPoints += $this->groupResults[$groupId]['group']->thirdPoints;
129 129
 		$this->groupResults[$groupId]['third']++;
130 130
 		return $this;
131 131
 	}
132
-	public function removeThird(string $groupId = ''){
132
+	public function removeThird(string $groupId = '') {
133 133
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
134 134
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->thirdPoints;
135 135
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->thirdPoints;
Please login to merge, or discard this patch.
Braces   +51 added lines, -17 removed lines patch added patch discarded remove patch
@@ -44,17 +44,23 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	public function addGameWith(Team $team, Group $group) {
47
-		if (!isset($this->gamesWith[$group->id][$team->id])) $this->gamesWith[$group->id][$team->id] = 0;
47
+		if (!isset($this->gamesWith[$group->id][$team->id])) {
48
+			$this->gamesWith[$group->id][$team->id] = 0;
49
+		}
48 50
 		$this->gamesWith[$group->id][$team->id]++;
49 51
 		return $this;
50 52
 	}
51 53
 	public function addGroup(Group $group) {
52
-		if (!isset($this->games[$group->id])) $this->games[$group->id] = [];
54
+		if (!isset($this->games[$group->id])) {
55
+			$this->games[$group->id] = [];
56
+		}
53 57
 		return $this;
54 58
 	}
55 59
 	public function addGame(Game $game) {
56 60
 		$group = $game->getGroup();
57
-		if (!isset($this->games[$group->id])) $this->games[$group->id] = [];
61
+		if (!isset($this->games[$group->id])) {
62
+			$this->games[$group->id] = [];
63
+		}
58 64
 		$this->games[$group->id][] = $game;
59 65
 		return $this;
60 66
 	}
@@ -67,88 +73,116 @@  discard block
 block discarded – undo
67 73
 	}
68 74
 
69 75
 	public function addWin(string $groupId = ''){
70
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
76
+		if (!isset($this->groupResults[$groupId])) {
77
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
78
+		}
71 79
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints;
72 80
 		$this->sumPoints += $this->groupResults[$groupId]['group']->winPoints;
73 81
 		$this->groupResults[$groupId]['wins']++;
74 82
 		return $this;
75 83
 	}
76 84
 	public function removeWin(string $groupId = ''){
77
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
85
+		if (!isset($this->groupResults[$groupId])) {
86
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
87
+		}
78 88
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->winPoints;
79 89
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->winPoints;
80 90
 		$this->groupResults[$groupId]['wins']--;
81 91
 		return $this;
82 92
 	}
83 93
 	public function addDraw(string $groupId = ''){
84
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
94
+		if (!isset($this->groupResults[$groupId])) {
95
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
96
+		}
85 97
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->drawPoints;
86 98
 		$this->sumPoints += $this->groupResults[$groupId]['group']->drawPoints;
87 99
 		$this->groupResults[$groupId]['draws']++;
88 100
 		return $this;
89 101
 	}
90 102
 	public function removeDraw(string $groupId = ''){
91
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
103
+		if (!isset($this->groupResults[$groupId])) {
104
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
105
+		}
92 106
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->drawPointsPoints;
93 107
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->drawPoints;
94 108
 		$this->groupResults[$groupId]['draws']--;
95 109
 		return $this;
96 110
 	}
97 111
 	public function addLoss(string $groupId = ''){
98
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
112
+		if (!isset($this->groupResults[$groupId])) {
113
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
114
+		}
99 115
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->lostPoints;
100 116
 		$this->sumPoints += $this->groupResults[$groupId]['group']->lostPoints;
101 117
 		$this->groupResults[$groupId]['losses']++;
102 118
 		return $this;
103 119
 	}
104 120
 	public function removeLoss(string $groupId = ''){
105
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
121
+		if (!isset($this->groupResults[$groupId])) {
122
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
123
+		}
106 124
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->lostPoints;
107 125
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->lostPoints;
108 126
 		$this->groupResults[$groupId]['losses']--;
109 127
 		return $this;
110 128
 	}
111 129
 	public function addSecond(string $groupId = ''){
112
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
130
+		if (!isset($this->groupResults[$groupId])) {
131
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
132
+		}
113 133
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->secondPoints;
114 134
 		$this->sumPoints += $this->groupResults[$groupId]['group']->secondPoints;
115 135
 		$this->groupResults[$groupId]['second']++;
116 136
 		return $this;
117 137
 	}
118 138
 	public function removeSecond(string $groupId = ''){
119
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
139
+		if (!isset($this->groupResults[$groupId])) {
140
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
141
+		}
120 142
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->secondPoints;
121 143
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->secondPoints;
122 144
 		$this->groupResults[$groupId]['second']--;
123 145
 		return $this;
124 146
 	}
125 147
 	public function addThird(string $groupId = ''){
126
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
148
+		if (!isset($this->groupResults[$groupId])) {
149
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
150
+		}
127 151
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->thirdPoints;
128 152
 		$this->sumPoints += $this->groupResults[$groupId]['group']->thirdPoints;
129 153
 		$this->groupResults[$groupId]['third']++;
130 154
 		return $this;
131 155
 	}
132 156
 	public function removeThird(string $groupId = ''){
133
-		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
157
+		if (!isset($this->groupResults[$groupId])) {
158
+			throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
159
+		}
134 160
 		$this->groupResults[$groupId]['points'] -= $this->groupResults[$groupId]['group']->thirdPoints;
135 161
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->thirdPoints;
136 162
 		$this->groupResults[$groupId]['third']--;
137 163
 		return $this;
138 164
 	}
139 165
 	public function sumPoints(array $groupIds = []) {
140
-		if (count($groupIds) === 0) return $this->sumPoints;
166
+		if (count($groupIds) === 0) {
167
+			return $this->sumPoints;
168
+		}
141 169
 		$sum = 0;
142 170
 		foreach ($groupIds as $gid) {
143
-			if (isset($this->groupResults[$gid])) $sum += $this->groupResults[$gid]['points'];
171
+			if (isset($this->groupResults[$gid])) {
172
+				$sum += $this->groupResults[$gid]['points'];
173
+			}
144 174
 		}
145 175
 		return $sum;
146 176
 	}
147 177
 	public function sumScore(array $groupIds = []) {
148
-		if (count($groupIds) === 0) return $this->sumScore;
178
+		if (count($groupIds) === 0) {
179
+			return $this->sumScore;
180
+		}
149 181
 		$sum = 0;
150 182
 		foreach ($groupIds as $gid) {
151
-			if (isset($this->groupResults[$gid])) $sum += $this->groupResults[$gid]['score'];
183
+			if (isset($this->groupResults[$gid])) {
184
+				$sum += $this->groupResults[$gid]['score'];
185
+			}
152 186
 		}
153 187
 		return $sum;
154 188
 	}
Please login to merge, or discard this patch.
src/TournamentGenerator/Round.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		return $this->name;
31 31
 	}
32 32
 
33
-	public function addGroup(Group ...$groups){
33
+	public function addGroup(Group ...$groups) {
34 34
 		foreach ($groups as $group) {
35 35
 			$this->groups[] = $group;
36 36
 		}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		$this->groups[] = $g->setSkip($this->allowSkip);
42 42
 		return $g;
43 43
 	}
44
-	public function getGroups(){
44
+	public function getGroups() {
45 45
 		$this->orderGroups();
46 46
 		return $this->groups;
47 47
 	}
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 		return array_map(function($a) { return $a->id; }, $this->groups);
51 51
 	}
52 52
 	public function orderGroups() {
53
-		usort($this->groups, function($a, $b){
54
-			return $a->getOrder() - $b->getOrder();
53
+		usort($this->groups, function($a, $b) {
54
+			return $a->getOrder()-$b->getOrder();
55 55
 		});
56 56
 	}
57 57
 
58
-	public function allowSkip(){
58
+	public function allowSkip() {
59 59
 		$this->allowSkip = true;
60 60
 		return $this;
61 61
 	}
62
-	public function disallowSkip(){
62
+	public function disallowSkip() {
63 63
 		$this->allowSkip = false;
64 64
 		return $this;
65 65
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		return $this->allowSkip;
72 72
 	}
73 73
 
74
-	public function genGames(){
74
+	public function genGames() {
75 75
 		foreach ($this->groups as $group) {
76 76
 			$group->genGames();
77 77
 			$this->games = array_merge($this->games, $group->orderGames());
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	public function getGames() {
82 82
 		return $this->games;
83 83
 	}
84
-	public function isPlayed(){
84
+	public function isPlayed() {
85 85
 		foreach ($this->groups as $group) {
86 86
 			if (!$group->isPlayed()) return false;
87 87
 		}
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 	public function addTeam(...$teams) {
92 92
 		foreach ($teams as $team) {
93
-			if ($team instanceof Team)  {
93
+			if ($team instanceof Team) {
94 94
 				$this->teams[] = $team;
95 95
 			}
96 96
 			elseif (gettype($team) === 'array') {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		return $this;
160 160
 	}
161 161
 
162
-	public function progress(bool $blank = false){
162
+	public function progress(bool $blank = false) {
163 163
 		foreach ($this->groups as $group) {
164 164
 			$group->progress($blank);
165 165
 		}
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,7 +83,9 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 	public function isPlayed(){
85 85
 		foreach ($this->groups as $group) {
86
-			if (!$group->isPlayed()) return false;
86
+			if (!$group->isPlayed()) {
87
+				return false;
88
+			}
87 89
 		}
88 90
 		return true;
89 91
 	}
@@ -92,10 +94,11 @@  discard block
 block discarded – undo
92 94
 		foreach ($teams as $team) {
93 95
 			if ($team instanceof Team)  {
94 96
 				$this->teams[] = $team;
95
-			}
96
-			elseif (gettype($team) === 'array') {
97
+			} elseif (gettype($team) === 'array') {
97 98
 				foreach ($team as $team2) {
98
-					if ($team2 instanceof Team) $this->teams[] = $team2;
99
+					if ($team2 instanceof Team) {
100
+						$this->teams[] = $team2;
101
+					}
99 102
 					$team2->groupResults[$this->id] = [
100 103
 						'group' => $this,
101 104
 						'points' => 0,
@@ -107,8 +110,9 @@  discard block
 block discarded – undo
107 110
 						'third'  => 0
108 111
 					];
109 112
 				}
113
+			} else {
114
+				throw new \Exception('Trying to add team which is not an instance of Team class');
110 115
 			}
111
-			else throw new \Exception('Trying to add team which is not an instance of Team class');
112 116
 		}
113 117
 		return $this;
114 118
 	}
@@ -137,7 +141,9 @@  discard block
 block discarded – undo
137 141
 
138 142
 	public function splitTeams(...$groups) {
139 143
 
140
-		if (count($groups) === 0) $groups = $this->getGroups();
144
+		if (count($groups) === 0) {
145
+			$groups = $this->getGroups();
146
+		}
141 147
 
142 148
 		foreach ($groups as $key => $value) {
143 149
 			if (gettype($value) === 'array') {
@@ -152,7 +158,9 @@  discard block
 block discarded – undo
152 158
 		while (count($teams) > 0) {
153 159
 			foreach ($groups as $group) {
154 160
 				if ($group instanceof Group) {
155
-					if (count($teams) > 0) $group->addTeam(array_shift($teams));
161
+					if (count($teams) > 0) {
162
+						$group->addTeam(array_shift($teams));
163
+					}
156 164
 				}
157 165
 			}
158 166
 		}
Please login to merge, or discard this patch.
src/TournamentGenerator/Progression.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,11 +33,17 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 
35 35
 	public function progress(bool $blank = false) {
36
-		if ($blank) $teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters);
37
-		else $teams = $this->from->sortTeams($this->filters);
36
+		if ($blank) {
37
+			$teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters);
38
+		} else {
39
+			$teams = $this->from->sortTeams($this->filters);
40
+		}
38 41
 
39
-		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len));
40
-		else $next = $teams;
42
+		if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) {
43
+			$next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len));
44
+		} else {
45
+			$next = $teams;
46
+		}
41 47
 
42 48
 		$i = 1;
43 49
 
@@ -45,12 +51,15 @@  discard block
 block discarded – undo
45 51
 			if ($blank) {
46 52
 				$this->to->addTeam(new BlankTeam($this.' - '.$i, $team));
47 53
 				$i++;
54
+			} else {
55
+				$team->sumPoints += $this->from->progressPoints;
48 56
 			}
49
-			else $team->sumPoints += $this->from->progressPoints;
50 57
 		}
51 58
 
52 59
 		$this->from->addProgressed($next);
53
-		if (!$blank) $this->to->addTeam($next);
60
+		if (!$blank) {
61
+			$this->to->addTeam($next);
62
+		}
54 63
 		return $this;
55 64
 	}
56 65
 
Please login to merge, or discard this patch.
src/TournamentGenerator/Category.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		$this->name = $name;
20 20
 	}
21 21
 
22
-	public function addRound(Round ...$rounds){
22
+	public function addRound(Round ...$rounds) {
23 23
 		foreach ($rounds as $round) {
24 24
 			if ($round instanceof Round) $this->rounds[] = $round;
25 25
 			else throw new \Exception('Trying to add round which is not an instance of Round class.');
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
 		$this->rounds[] = $r->setSkip($this->allowSkip);
32 32
 		return $r;
33 33
 	}
34
-	public function getRounds(){
34
+	public function getRounds() {
35 35
 		return $this->rounds;
36 36
 	}
37 37
 
38
-	public function allowSkip(){
38
+	public function allowSkip() {
39 39
 		$this->allowSkip = true;
40 40
 		return $this;
41 41
 	}
42
-	public function disallowSkip(){
42
+	public function disallowSkip() {
43 43
 		$this->allowSkip = false;
44 44
 		return $this;
45 45
 	}
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,8 +21,11 @@  discard block
 block discarded – undo
21 21
 
22 22
 	public function addRound(Round ...$rounds){
23 23
 		foreach ($rounds as $round) {
24
-			if ($round instanceof Round) $this->rounds[] = $round;
25
-			else throw new \Exception('Trying to add round which is not an instance of Round class.');
24
+			if ($round instanceof Round) {
25
+				$this->rounds[] = $round;
26
+			} else {
27
+				throw new \Exception('Trying to add round which is not an instance of Round class.');
28
+			}
26 29
 		}
27 30
 		return $this;
28 31
 	}
@@ -63,7 +66,9 @@  discard block
 block discarded – undo
63 66
 		return $t;
64 67
 	}
65 68
 	public function getTeams() {
66
-		if (count($this->teams) > 0) return $this->teams;
69
+		if (count($this->teams) > 0) {
70
+			return $this->teams;
71
+		}
67 72
 		$teams = [];
68 73
 		foreach ($this->rounds as $round) {
69 74
 			$teams = array_merge($teams, $round->getTeams());
@@ -82,7 +87,9 @@  discard block
 block discarded – undo
82 87
 
83 88
 	public function splitTeams(...$rounds) {
84 89
 
85
-		if (count($rounds) === 0) $rounds = $this->getRounds();
90
+		if (count($rounds) === 0) {
91
+			$rounds = $this->getRounds();
92
+		}
86 93
 
87 94
 		$teams = $this->getTeams();
88 95
 		shuffle($teams);
@@ -102,7 +109,9 @@  discard block
 block discarded – undo
102 109
 
103 110
 	public function genGamesSimulate() {
104 111
 		$games = [];
105
-		if (count($this->rounds) <= 0) throw new \Exception('There are no rounds to simulate games from.');
112
+		if (count($this->rounds) <= 0) {
113
+			throw new \Exception('There are no rounds to simulate games from.');
114
+		}
106 115
 		foreach ($this->rounds as $round) {
107 116
 			$games = array_merge($games, $round->genGames());
108 117
 			$round->simulate()->progress(true)->resetGames();
Please login to merge, or discard this patch.
src/TournamentGenerator/Tournament.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 	private $allowSkip = false;
22 22
 
23
-	function __construct(string $name = ''){
23
+	function __construct(string $name = '') {
24 24
 		$this->name = $name;
25 25
 	}
26 26
 	public function __toString() {
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	public function getCategoryWait() {
64 64
 		return $this->expectedCategoryWait;
65 65
 	}
66
-	public function getTournamentTime(){
66
+	public function getTournamentTime() {
67 67
 		$games = count($this->getGames());
68 68
 		return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait;
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
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		return $this->allowSkip;
85 85
 	}
86 86
 
87
-	public function addCategory(Category ...$categories){
87
+	public function addCategory(Category ...$categories) {
88 88
 		foreach ($categories as $category) {
89 89
 			if ($category instanceof Category) $this->categories[] = $category;
90 90
 			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
Please login to merge, or discard this patch.
Braces   +25 added lines, -9 removed lines patch added patch discarded remove patch
@@ -86,8 +86,11 @@  discard block
 block discarded – undo
86 86
 
87 87
 	public function addCategory(Category ...$categories){
88 88
 		foreach ($categories as $category) {
89
-			if ($category instanceof Category) $this->categories[] = $category;
90
-			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
89
+			if ($category instanceof Category) {
90
+				$this->categories[] = $category;
91
+			} else {
92
+				throw new \Exception('Trying to add category which is not an instance of the Category class.');
93
+			}
91 94
 		}
92 95
 		return $this;
93 96
 	}
@@ -102,8 +105,11 @@  discard block
 block discarded – undo
102 105
 
103 106
 	public function addRound(Round ...$rounds) {
104 107
 		foreach ($rounds as $round) {
105
-			if ($round instanceof Round) $this->rounds[] = $round;
106
-			else throw new \Exception('Trying to add round which is not an instance of the Round class.');
108
+			if ($round instanceof Round) {
109
+				$this->rounds[] = $round;
110
+			} else {
111
+				throw new \Exception('Trying to add round which is not an instance of the Round class.');
112
+			}
107 113
 		}
108 114
 		return $this;
109 115
 	}
@@ -143,7 +149,9 @@  discard block
 block discarded – undo
143 149
 			$teams = array_merge($teams, $round->getTeams());
144 150
 		}
145 151
 		$this->teams = \array_unique($teams);
146
-		if ($ordered) $this->sortTeams($ordering);
152
+		if ($ordered) {
153
+			$this->sortTeams($ordering);
154
+		}
147 155
 		return $this->teams;
148 156
 	}
149 157
 	public function sortTeams($ordering = \TournamentGenerator\Constants::POINTS) {
@@ -166,7 +174,9 @@  discard block
 block discarded – undo
166 174
 
167 175
 	public function splitTeams(Round ...$wheres) {
168 176
 
169
-		if (count($wheres) === 0) $wheres = $this->getRounds();
177
+		if (count($wheres) === 0) {
178
+			$wheres = $this->getRounds();
179
+		}
170 180
 
171 181
 		foreach ($wheres as $key => $value) {
172 182
 			if (gettype($value) === 'array') {
@@ -181,7 +191,9 @@  discard block
 block discarded – undo
181 191
 
182 192
 		while (count($teams) > 0) {
183 193
 			foreach ($wheres as $where) {
184
-				if (count($teams) > 0) $where->addTeam(array_shift($teams));
194
+				if (count($teams) > 0) {
195
+					$where->addTeam(array_shift($teams));
196
+				}
185 197
 			}
186 198
 		}
187 199
 		foreach ($wheres as $where) {
@@ -193,13 +205,17 @@  discard block
 block discarded – undo
193 205
 	public function genGamesSimulate(bool $returnTime = false) {
194 206
 		$games = Utilis\Simulator::simulateTournament($this);
195 207
 
196
-		if ($returnTime) return $this->getTournamentTime();
208
+		if ($returnTime) {
209
+			return $this->getTournamentTime();
210
+		}
197 211
 		return $games;
198 212
 	}
199 213
 	public function genGamesSimulateReal(bool $returnTime = false) {
200 214
 		$games = Utilis\Simulator::simulateTournamentReal($this);
201 215
 
202
-		if ($returnTime) return $this->getTournamentTime();
216
+		if ($returnTime) {
217
+			return $this->getTournamentTime();
218
+		}
203 219
 		return $games;
204 220
 	}
205 221
 
Please login to merge, or discard this patch.
tests/TournamentTest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -263,13 +263,13 @@  discard block
 block discarded – undo
263 263
 		$round1 = $tournament->round('Round1');
264 264
 		$round2 = $tournament->round('Round1');
265 265
 
266
-		$category1->addTeam(new \TournamentGenerator\Team('Team1'),new \TournamentGenerator\Team('Team2'),new \TournamentGenerator\Team('Team3'));
267
-		$category2->addTeam(new \TournamentGenerator\Team('Team4'),new \TournamentGenerator\Team('Team5'),new \TournamentGenerator\Team('Team6'));
266
+		$category1->addTeam(new \TournamentGenerator\Team('Team1'), new \TournamentGenerator\Team('Team2'), new \TournamentGenerator\Team('Team3'));
267
+		$category2->addTeam(new \TournamentGenerator\Team('Team4'), new \TournamentGenerator\Team('Team5'), new \TournamentGenerator\Team('Team6'));
268 268
 
269
-		$round1->addTeam(new \TournamentGenerator\Team('Team7'),new \TournamentGenerator\Team('Team8'),new \TournamentGenerator\Team('Team9'));
270
-		$round2->addTeam(new \TournamentGenerator\Team('Team10'),new \TournamentGenerator\Team('Team11'),new \TournamentGenerator\Team('Team12'));
269
+		$round1->addTeam(new \TournamentGenerator\Team('Team7'), new \TournamentGenerator\Team('Team8'), new \TournamentGenerator\Team('Team9'));
270
+		$round2->addTeam(new \TournamentGenerator\Team('Team10'), new \TournamentGenerator\Team('Team11'), new \TournamentGenerator\Team('Team12'));
271 271
 
272
-		$tournament->addTeam(new \TournamentGenerator\Team('Team13'),new \TournamentGenerator\Team('Team14'),new \TournamentGenerator\Team('Team15'));
272
+		$tournament->addTeam(new \TournamentGenerator\Team('Team13'), new \TournamentGenerator\Team('Team14'), new \TournamentGenerator\Team('Team15'));
273 273
 
274 274
 		$this->assertCount(15, $tournament->getTeams());
275 275
 		// Test if teams does not duplicate
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 		$tournament = new \TournamentGenerator\Tournament('Name of tournament 1');
284 284
 
285
-		for ($i=1; $i <= 8; $i++) {
285
+		for ($i = 1; $i <= 8; $i++) {
286 286
 			$tournament->team('Team '.$i);
287 287
 		}
288 288
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 
304 304
 		$tournament = new \TournamentGenerator\Tournament('Name of tournament 1');
305 305
 
306
-		for ($i=1; $i <= 8; $i++) {
306
+		for ($i = 1; $i <= 8; $i++) {
307 307
 			$tournament->team('Team '.$i);
308 308
 		}
309 309
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			->setGameWait(2) // SET TIME BETWEEN GAMES TO 2 MINUTES
331 331
 			->setRoundWait(0); // SET TIME BETWEEN ROUNDS TO 0 MINUTES
332 332
 
333
-		for ($i=1; $i <= 8; $i++) {
333
+		for ($i = 1; $i <= 8; $i++) {
334 334
 			$tournament->team('Team '.$i);
335 335
 		}
336 336
 		// Create a round and a final round
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
 		$group = $round->group('Group name');
429 429
 
430
-		for ($i=1; $i <= 4; $i++) {
430
+		for ($i = 1; $i <= 4; $i++) {
431 431
 			$tournament->team('Team '.$i);
432 432
 		}
433 433
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 
461 461
 		$group = $round->group('Group name');
462 462
 
463
-		for ($i=1; $i <= 4; $i++) {
463
+		for ($i = 1; $i <= 4; $i++) {
464 464
 			$tournament->team('Team '.$i);
465 465
 		}
466 466
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
 		$group = $round->group('Group name');
494 494
 
495
-		for ($i=1; $i <= 4; $i++) {
495
+		for ($i = 1; $i <= 4; $i++) {
496 496
 			$tournament->team('Team '.$i);
497 497
 		}
498 498
 
Please login to merge, or discard this patch.