Test Failed
Branch master (723ca8)
by Tomáš
02:22
created
src/TournamentGenerator/Utilis/Sorter/Teams.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
 	/**
21
-	* @var array $ids Stores ids of groups get scores and points from
22
-	*/
21
+	 * @var array $ids Stores ids of groups get scores and points from
22
+	 */
23 23
 	protected static $ids = [];
24 24
 
25 25
 	/**
26
-	* Sort teams in group by defined ordering type
27
-	*
28
-	* @param array &$teams                     Array of teams to be sorted
29
-	* @param \TournamentGenerator\Group $group Group to get the results from
30
-	* @param string $ordering                  What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE)
31
-	*
32
-	* @return array Sorted array of teams
33
-	*/
26
+	 * Sort teams in group by defined ordering type
27
+	 *
28
+	 * @param array &$teams                     Array of teams to be sorted
29
+	 * @param \TournamentGenerator\Group $group Group to get the results from
30
+	 * @param string $ordering                  What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE)
31
+	 *
32
+	 * @return array Sorted array of teams
33
+	 */
34 34
 	public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) {
35 35
 		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`');
36 36
 
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 	}
50 50
 
51 51
 	/**
52
-	* Sort teams in round by defined ordering type
53
-	*
54
-	* @param array &$teams                     Array of teams to be sorted
55
-	* @param \TournamentGenerator\Round $round Round to get the results from
56
-	* @param string $ordering                  What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE)
57
-	*
58
-	* @return array Sorted array of teams
59
-	*/
52
+	 * Sort teams in round by defined ordering type
53
+	 *
54
+	 * @param array &$teams                     Array of teams to be sorted
55
+	 * @param \TournamentGenerator\Round $round Round to get the results from
56
+	 * @param string $ordering                  What to order by (\TournamentGenerator\Constants::POINTS / \TournamentGenerator\Constants::SCORE)
57
+	 *
58
+	 * @return array Sorted array of teams
59
+	 */
60 60
 	public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) {
61 61
 		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`');
62 62
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	}
76 76
 
77 77
 	/**
78
-	* Sorter function for uasort by points
79
-	*/
78
+	 * Sorter function for uasort by points
79
+	 */
80 80
 	private static function sortTeamsByPoints($a, $b) {
81 81
 		$groupsIds = self::$ids;
82 82
 		if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0;
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 		return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1);
85 85
 	}
86 86
 	/**
87
-	* Sorter function for uasort by score
88
-	*/
87
+	 * Sorter function for uasort by score
88
+	 */
89 89
 	private static function sortTeamsByScore($a, $b) {
90 90
 		$groupsIds = self::$ids;
91 91
 		if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0;
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@  discard block
 block discarded – undo
32 32
 	* @return array Sorted array of teams
33 33
 	*/
34 34
 	public static function sortGroup(array &$teams, \TournamentGenerator\Group $group, string $ordering = \TournamentGenerator\Constants::POINTS) {
35
-		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`');
35
+		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) {
36
+			throw new \Exception('Unknown ordering type `'.$ordering.'`');
37
+		}
36 38
 
37 39
 		self::$ids = [$group->getId()];
38 40
 
@@ -58,7 +60,9 @@  discard block
 block discarded – undo
58 60
 	* @return array Sorted array of teams
59 61
 	*/
60 62
 	public static function sortRound(array &$teams, \TournamentGenerator\Round $round, string $ordering = \TournamentGenerator\Constants::POINTS) {
61
-		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown ordering type `'.$ordering.'`');
63
+		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) {
64
+			throw new \Exception('Unknown ordering type `'.$ordering.'`');
65
+		}
62 66
 
63 67
 		self::$ids = $round->getGroupsIds();
64 68
 
@@ -79,8 +83,12 @@  discard block
 block discarded – undo
79 83
 	*/
80 84
 	private static function sortTeamsByPoints($a, $b) {
81 85
 		$groupsIds = self::$ids;
82
-		if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0;
83
-		if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1);
86
+		if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds) && $a->sumScore($groupsIds) === $b->sumScore($groupsIds)) {
87
+			return 0;
88
+		}
89
+		if ($a->sumPoints($groupsIds) === $b->sumPoints($groupsIds)) {
90
+			return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1);
91
+		}
84 92
 		return ($a->sumPoints($groupsIds) > $b->sumPoints($groupsIds) ? -1 : 1);
85 93
 	}
86 94
 	/**
@@ -88,7 +96,9 @@  discard block
 block discarded – undo
88 96
 	*/
89 97
 	private static function sortTeamsByScore($a, $b) {
90 98
 		$groupsIds = self::$ids;
91
-		if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) return 0;
99
+		if ($a->sumScore($groupsIds) === $b->sumScore($groupsIds)) {
100
+			return 0;
101
+		}
92 102
 		return ($a->sumScore($groupsIds) > $b->sumScore($groupsIds) ? -1 : 1);
93 103
 	}
94 104
 
Please login to merge, or discard this patch.
src/TournamentGenerator/Round.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		return $this->id;
41 41
 	}
42 42
 
43
-	public function addGroup(Group ...$groups){
43
+	public function addGroup(Group ...$groups) {
44 44
 		foreach ($groups as $group) {
45 45
 			$this->groups[] = $group;
46 46
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->groups[] = $g->setSkip($this->allowSkip);
52 52
 		return $g;
53 53
 	}
54
-	public function getGroups(){
54
+	public function getGroups() {
55 55
 		$this->orderGroups();
56 56
 		return $this->groups;
57 57
 	}
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
 		return array_map(function($a) { return $a->getId(); }, $this->groups);
61 61
 	}
62 62
 	public function orderGroups() {
63
-		usort($this->groups, function($a, $b){
64
-			return $a->getOrder() - $b->getOrder();
63
+		usort($this->groups, function($a, $b) {
64
+			return $a->getOrder()-$b->getOrder();
65 65
 		});
66 66
 		return $this->groups;
67 67
 	}
68 68
 
69
-	public function allowSkip(){
69
+	public function allowSkip() {
70 70
 		$this->allowSkip = true;
71 71
 		return $this;
72 72
 	}
73
-	public function disallowSkip(){
73
+	public function disallowSkip() {
74 74
 		$this->allowSkip = false;
75 75
 		return $this;
76 76
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		return $this->allowSkip;
83 83
 	}
84 84
 
85
-	public function genGames(){
85
+	public function genGames() {
86 86
 		foreach ($this->groups as $group) {
87 87
 			$group->genGames();
88 88
 			$this->games = array_merge($this->games, $group->orderGames());
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	public function getGames() {
93 93
 		return $this->games;
94 94
 	}
95
-	public function isPlayed(){
95
+	public function isPlayed() {
96 96
 		if (count($this->games) === 0) return false;
97 97
 		foreach ($this->groups as $group) {
98 98
 			if (!$group->isPlayed()) return false;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		return $this;
155 155
 	}
156 156
 
157
-	public function progress(bool $blank = false){
157
+	public function progress(bool $blank = false) {
158 158
 		foreach ($this->groups as $group) {
159 159
 			$group->progress($blank);
160 160
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -93,9 +93,13 @@  discard block
 block discarded – undo
93 93
 		return $this->games;
94 94
 	}
95 95
 	public function isPlayed(){
96
-		if (count($this->games) === 0) return false;
96
+		if (count($this->games) === 0) {
97
+			return false;
98
+		}
97 99
 		foreach ($this->groups as $group) {
98
-			if (!$group->isPlayed()) return false;
100
+			if (!$group->isPlayed()) {
101
+				return false;
102
+			}
99 103
 		}
100 104
 		return true;
101 105
 	}
@@ -131,14 +135,18 @@  discard block
 block discarded – undo
131 135
 
132 136
 	public function splitTeams(Group ...$groups) {
133 137
 
134
-		if (count($groups) === 0) $groups = $this->getGroups();
138
+		if (count($groups) === 0) {
139
+			$groups = $this->getGroups();
140
+		}
135 141
 
136 142
 		$teams = $this->getTeams();
137 143
 		shuffle($teams);
138 144
 
139 145
 		while (count($teams) > 0) {
140 146
 			foreach ($groups as $group) {
141
-				if (count($teams) > 0) $group->addTeam(array_shift($teams));
147
+				if (count($teams) > 0) {
148
+					$group->addTeam(array_shift($teams));
149
+				}
142 150
 			}
143 151
 		}
144 152
 		return $this;
Please login to merge, or discard this patch.
src/TournamentGenerator/Filter.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
 			if (gettype($filter) === 'array') {
26 26
 				$this->filterMulti($teams, $filter, $key);
27 27
 				continue;
28
-			}
29
-			elseif ($filter instanceof TeamFilter) {
28
+			} elseif ($filter instanceof TeamFilter) {
30 29
 				$teams = array_filter($teams, function($team) use ($filter) {return $filter->validate($team, $this->group->getId(), 'sum', $this->group); });
31 30
 				continue;
32 31
 			}
@@ -39,12 +38,18 @@  discard block
 block discarded – undo
39 38
 		switch (strtolower($how)) {
40 39
 			case 'and':
41 40
 				foreach ($teams as $tkey => $team) {
42
-					if (!$this->filterAnd($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
41
+					if (!$this->filterAnd($team, $filters)) {
42
+						unset($teams[$tkey]);
43
+					}
44
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
43 45
 				}
44 46
 				return true;
45 47
 			case 'or':
46 48
 				foreach ($teams as $tkey => $team) {
47
-					if (!$this->filterOr($team, $filters)) unset($teams[$tkey]); // IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
49
+					if (!$this->filterOr($team, $filters)) {
50
+						unset($teams[$tkey]);
51
+					}
52
+					// IF FILTER IS NOT VALIDATED REMOVE TEAM FROM RETURN ARRAY
48 53
 				}
49 54
 				return true;
50 55
 		}
@@ -56,19 +61,24 @@  discard block
 block discarded – undo
56 61
 			if (gettype($value) === 'array') {
57 62
 				switch (strtolower($key)) {
58 63
 					case 'and':
59
-						if ($this->filterAnd($team, $value)) return false;
64
+						if ($this->filterAnd($team, $value)) {
65
+							return false;
66
+						}
60 67
 						break;
61 68
 					case 'or':
62
-						if ($this->filterOr($team, $value)) return false;
69
+						if ($this->filterOr($team, $value)) {
70
+							return false;
71
+						}
63 72
 						break;
64 73
 					default:
65 74
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
66 75
 						break;
67 76
 				}
68 77
 				continue;
69
-			}
70
-			elseif ($value instanceof TeamFilter) {
71
-				if (!$value->validate($team, $this->group->getId(), 'sum', $this->group)) return false;
78
+			} elseif ($value instanceof TeamFilter) {
79
+				if (!$value->validate($team, $this->group->getId(), 'sum', $this->group)) {
80
+					return false;
81
+				}
72 82
 				continue;
73 83
 			}
74 84
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
@@ -80,19 +90,24 @@  discard block
 block discarded – undo
80 90
 			if (gettype($value) === 'array') {
81 91
 				switch (strtolower($key)) {
82 92
 					case 'and':
83
-						if ($this->filterAnd($team, $value)) return true;
93
+						if ($this->filterAnd($team, $value)) {
94
+							return true;
95
+						}
84 96
 						break;
85 97
 					case 'or':
86
-						if ($this->filterOr($team, $value)) return true;
98
+						if ($this->filterOr($team, $value)) {
99
+							return true;
100
+						}
87 101
 						break;
88 102
 					default:
89 103
 						throw new \Exception('Unknown opperand type "'.$key.'". Expected "and" or "or".');
90 104
 						break;
91 105
 				}
92 106
 				continue;
93
-			}
94
-			elseif ($value instanceof TeamFilter) {
95
-				if (!$value->validate($team, $this->group->getId(), 'sum', $this->group)) return true;
107
+			} elseif ($value instanceof TeamFilter) {
108
+				if (!$value->validate($team, $this->group->getId(), 'sum', $this->group)) {
109
+					return true;
110
+				}
96 111
 				continue;
97 112
 			}
98 113
 			throw new \Exception('Filer ['.$key.'] is not an instance of TeamFilter class');
Please login to merge, or discard this patch.
src/TournamentGenerator/Game.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* $results = array (
84
-	* * team->getId() => team->score
85
-	* )
86
-	*/
83
+	 * $results = array (
84
+	 * * team->getId() => team->score
85
+	 * )
86
+	 */
87 87
 	public function setResults(array $results = []) {
88 88
 		if (count($this->results) === 0) $this->resetResults();
89 89
 		arsort($results);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,11 +66,11 @@
 block discarded – undo
66 66
 		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));
67 67
 		return $this;
68 68
 	}
69
-	public function getTeams(){
69
+	public function getTeams() {
70 70
 		return $this->teams;
71 71
 	}
72
-	public function getTeamsIds(){
73
-		return array_map(function($a){ return $a->getId(); }, $this->teams);
72
+	public function getTeamsIds() {
73
+		return array_map(function($a) { return $a->getId(); }, $this->teams);
74 74
 	}
75 75
 	public function getTeam(string $id) {
76 76
 		foreach ($this->teams as $team) {
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -33,11 +33,15 @@  discard block
 block discarded – undo
33 33
 		$this->teams = $teams;
34 34
 		foreach ($this->teams as $team) {
35 35
 			foreach ($this->teams as $team2) {
36
-				if ($team === $team2) continue;
36
+				if ($team === $team2) {
37
+					continue;
38
+				}
37 39
 				$team->addGameWith($team2, $group);
38 40
 			}
39 41
 		}
40
-		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));
42
+		if (count($error) > 0) {
43
+			throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
44
+		}
41 45
 	}
42 46
 
43 47
 	public function getGroup() {
@@ -56,14 +60,18 @@  discard block
 block discarded – undo
56 60
 			$team->addGame($this);
57 61
 
58 62
 			foreach ($this->teams as $team2) {
59
-				if ($team === $team2) continue;
63
+				if ($team === $team2) {
64
+					continue;
65
+				}
60 66
 				if ($team instanceof Team) {
61 67
 					$team->addGameWith($team2, $this->group);
62 68
 					$team2->addGameWith($team, $this->group);
63 69
 				}
64 70
 			}
65 71
 		}
66
-		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));
72
+		if (count($error) > 0) {
73
+			throw new \Exception('Trying to add teams ('.count($error).') that are not instance of Team class'.PHP_EOL.print_r($error, true));
74
+		}
67 75
 		return $this;
68 76
 	}
69 77
 	public function getTeams(){
@@ -74,7 +82,9 @@  discard block
 block discarded – undo
74 82
 	}
75 83
 	public function getTeam(string $id) {
76 84
 		foreach ($this->teams as $team) {
77
-			if ($team->getId() === $id) return $team;
85
+			if ($team->getId() === $id) {
86
+				return $team;
87
+			}
78 88
 		}
79 89
 		return false;
80 90
 	}
@@ -85,13 +95,17 @@  discard block
 block discarded – undo
85 95
 	* )
86 96
 	*/
87 97
 	public function setResults(array $results = []) {
88
-		if (count($this->results) === 0) $this->resetResults();
98
+		if (count($this->results) === 0) {
99
+			$this->resetResults();
100
+		}
89 101
 		arsort($results);
90 102
 		$inGame = /** @scrutinizer ignore-call */ $this->group->getInGame();
91 103
 		$i = 1;
92 104
 		foreach ($results as $id => $score) {
93 105
 			$team = $this->getTeam($id);
94
-			if ($team === false) throw new \Exception('Couldn\'t find team with id of "'.$id.'"');
106
+			if ($team === false) {
107
+				throw new \Exception('Couldn\'t find team with id of "'.$id.'"');
108
+			}
95 109
 			$this->results[$team->getId()] = ['score' => $score];
96 110
 			$team->sumScore += $score;
97 111
 			$prev = prev($results);
@@ -118,13 +132,11 @@  discard block
 block discarded – undo
118 132
 			$this->drawIds[] = $team->getId();
119 133
 			$team->addDraw($this->group->getId());
120 134
 			$this->results[$team->getId()] += ['points' => $this->group->drawPoints, 'type' => 'draw'];
121
-		}
122
-		elseif ($i === 1) {
135
+		} elseif ($i === 1) {
123 136
 			$this->winId = $team->getId();
124 137
 			$team->addWin($this->group->getId());
125 138
 			$this->results[$team->getId()] += ['points' => $this->group->winPoints, 'type' => 'win'];
126
-		}
127
-		else {
139
+		} else {
128 140
 			$this->lossId = $team->getId();
129 141
 			$team->addLoss($this->group->getId());
130 142
 			$this->results[$team->getId()] += ['points' => $this->group->lostPoints, 'type' => 'loss'];
@@ -223,7 +235,9 @@  discard block
 block discarded – undo
223 235
 	}
224 236
 
225 237
 	public function isPlayed() {
226
-		if (count($this->results) > 0) return true;
238
+		if (count($this->results) > 0) {
239
+			return true;
240
+		}
227 241
 		return false;
228 242
 	}
229 243
 }
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
 			$this->categories[] = $category;
90 90
 		}
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -141,7 +141,9 @@  discard block
 block discarded – undo
141 141
 			$teams = array_merge($teams, $round->getTeams());
142 142
 		}
143 143
 		$this->teams = \array_unique($teams);
144
-		if ($ordered) $this->sortTeams($ordering);
144
+		if ($ordered) {
145
+			$this->sortTeams($ordering);
146
+		}
145 147
 		return $this->teams;
146 148
 	}
147 149
 	public function sortTeams($ordering = \TournamentGenerator\Constants::POINTS) {
@@ -164,14 +166,18 @@  discard block
 block discarded – undo
164 166
 
165 167
 	public function splitTeams(Round ...$wheres) {
166 168
 
167
-		if (count($wheres) === 0) $wheres = $this->getRounds();
169
+		if (count($wheres) === 0) {
170
+			$wheres = $this->getRounds();
171
+		}
168 172
 
169 173
 		$teams = $this->getTeams();
170 174
 		shuffle($teams);
171 175
 
172 176
 		while (count($teams) > 0) {
173 177
 			foreach ($wheres as $where) {
174
-				if (count($teams) > 0) $where->addTeam(array_shift($teams));
178
+				if (count($teams) > 0) {
179
+					$where->addTeam(array_shift($teams));
180
+				}
175 181
 			}
176 182
 		}
177 183
 		foreach ($wheres as $where) {
@@ -183,13 +189,17 @@  discard block
 block discarded – undo
183 189
 	public function genGamesSimulate(bool $returnTime = false) {
184 190
 		$games = Utilis\Simulator::simulateTournament($this);
185 191
 
186
-		if ($returnTime) return $this->getTournamentTime();
192
+		if ($returnTime) {
193
+			return $this->getTournamentTime();
194
+		}
187 195
 		return $games;
188 196
 	}
189 197
 	public function genGamesSimulateReal(bool $returnTime = false) {
190 198
 		$games = Utilis\Simulator::simulateTournamentReal($this);
191 199
 
192
-		if ($returnTime) return $this->getTournamentTime();
200
+		if ($returnTime) {
201
+			return $this->getTournamentTime();
202
+		}
193 203
 		return $games;
194 204
 	}
195 205
 
Please login to merge, or discard this patch.
src/TournamentGenerator/Group.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 		return $this->id;
51 51
 	}
52 52
 
53
-	public function allowSkip(){
53
+	public function allowSkip() {
54 54
 		$this->generator->allowSkip();
55 55
 		return $this;
56 56
 	}
57
-	public function disallowSkip(){
57
+	public function disallowSkip() {
58 58
 		$this->generator->disallowSkip();
59 59
 		return $this;
60 60
 	}
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		}
162 162
 	}
163 163
 	public function addProgressed(...$teams) {
164
-		$this->progressed = array_merge($this->progressed, array_filter($teams, function($a){return $a instanceof Team;}));
165
-		foreach (array_filter($teams, function($a){return is_array($a);}) as $team) {
164
+		$this->progressed = array_merge($this->progressed, array_filter($teams, function($a) {return $a instanceof Team; }));
165
+		foreach (array_filter($teams, function($a) {return is_array($a); }) as $team) {
166 166
 			$this->progressed = array_merge($this->progressed, array_filter($team, function($a) {
167 167
 				return ($a instanceof Team);
168 168
 			}));
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 		$this->games[] = $g;
184 184
 		return $g;
185 185
 	}
186
-	public function addGame(...$games){
187
-		$this->games = array_merge($this->games, array_filter($games, function($a){ return ($a instanceof Game); }));
186
+	public function addGame(...$games) {
187
+		$this->games = array_merge($this->games, array_filter($games, function($a) { return ($a instanceof Game); }));
188 188
 
189
-		foreach (array_filter($games, function($a){return is_array($a);}) as $key => $game) {
190
-			$this->games = array_merge($this->games, array_filter($game, function($a){ return ($a instanceof Game); }));
189
+		foreach (array_filter($games, function($a) {return is_array($a); }) as $key => $game) {
190
+			$this->games = array_merge($this->games, array_filter($game, function($a) { return ($a instanceof Game); }));
191 191
 		}
192 192
 		return $this;
193 193
 	}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 		return $this;
211 211
 	}
212
-	public function isPlayed(){
212
+	public function isPlayed() {
213 213
 		if (count($this->games) === 0) return false;
214 214
 		foreach ($this->games as $game) {
215 215
 			if (!$game->isPlayed()) return false;
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,7 +100,9 @@  discard block
 block discarded – undo
100 100
 		return $t;
101 101
 	}
102 102
 	public function sortTeams(array $filters = [], $ordering = null) {
103
-		if (!isset($ordering)) $ordering = $this->ordering;
103
+		if (!isset($ordering)) {
104
+			$ordering = $this->ordering;
105
+		}
104 106
 		Utilis\Sorter\Teams::sortGroup($this->teams, $this, $ordering);
105 107
 		return $this->getTeams($filters);
106 108
 	}
@@ -130,7 +132,9 @@  discard block
 block discarded – undo
130 132
 	}
131 133
 
132 134
 	public function setOrdering(string $ordering = \TournamentGenerator\Constants::POINTS) {
133
-		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) throw new \Exception('Unknown group ordering: '.$ordering);
135
+		if (!in_array($ordering, \TournamentGenerator\Constants::OrderingTypes)) {
136
+			throw new \Exception('Unknown group ordering: '.$ordering);
137
+		}
134 138
 		$this->ordering = $ordering;
135 139
 		return $this;
136 140
 	}
@@ -195,7 +199,9 @@  discard block
 block discarded – undo
195 199
 		return $this->games;
196 200
 	}
197 201
 	public function orderGames() {
198
-		if (count($this->games) <= 4) return $this->games;
202
+		if (count($this->games) <= 4) {
203
+			return $this->games;
204
+		}
199 205
 		$this->games = $this->generator->orderGames();
200 206
 		return $this->games;
201 207
 	}
@@ -210,9 +216,13 @@  discard block
 block discarded – undo
210 216
 		return $this;
211 217
 	}
212 218
 	public function isPlayed(){
213
-		if (count($this->games) === 0) return false;
219
+		if (count($this->games) === 0) {
220
+			return false;
221
+		}
214 222
 		foreach ($this->games as $game) {
215
-			if (!$game->isPlayed()) return false;
223
+			if (!$game->isPlayed()) {
224
+				return false;
225
+			}
216 226
 		}
217 227
 		return true;
218 228
 	}
Please login to merge, or discard this patch.