Test Failed
Branch master (723ca8)
by Tomáš
02:22
created
src/TournamentGenerator/Utilis/Sorter/Games.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			// CYCLE 6
71 71
 			// FIRST AVAILABLE GAME
72
-			$this->moveCalculatedGames(array_shift($games),$teams);
72
+			$this->moveCalculatedGames(array_shift($games), $teams);
73 73
 		}
74 74
 
75 75
 		return $this->games;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	private function cycle1(array &$games, array &$teams) {
80 80
 		$found = false;
81 81
 		foreach ($games as $key => $game) {
82
-			if ($this->orderCheckTeamsVal($game, $teams, [4,5,6,7])) {
83
-				$this->moveCalculatedGames($game,$teams);
82
+			if ($this->orderCheckTeamsVal($game, $teams, [4, 5, 6, 7])) {
83
+				$this->moveCalculatedGames($game, $teams);
84 84
 				unset($games[$key]);
85 85
 				$found = true;
86 86
 				break;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	private function cycle2(array &$games, array &$teams) {
93 93
 		$found = false;
94 94
 		foreach ($games as $key => $game) {
95
-			if ($this->orderCheckTeamsVal($game, $teams, [6,7])) {
96
-				$this->moveCalculatedGames($game,$teams);
95
+			if ($this->orderCheckTeamsVal($game, $teams, [6, 7])) {
96
+				$this->moveCalculatedGames($game, $teams);
97 97
 				unset($games[$key]);
98 98
 				$found = true;
99 99
 				break;
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	private function cycle3(array &$games, array &$teams) {
107 107
 		$found = false;
108 108
 		foreach ($games as $key => $game) {
109
-			if ($this->orderCheckTeamsVal($game, $teams, [7], [1,2,3])) {
110
-				$this->moveCalculatedGames($game,$teams);
109
+			if ($this->orderCheckTeamsVal($game, $teams, [7], [1, 2, 3])) {
110
+				$this->moveCalculatedGames($game, $teams);
111 111
 				unset($games[$key]);
112 112
 				$found = true;
113 113
 				break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$found = false;
121 121
 		foreach ($games as $key => $game) {
122 122
 			if ($this->orderCheckTeamsVal($game, $teams, [7])) {
123
-				$this->moveCalculatedGames($game,$teams);
123
+				$this->moveCalculatedGames($game, $teams);
124 124
 				unset($games[$key]);
125 125
 				$found = true;
126 126
 				break;
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	private function cycle5(array &$games, array &$teams) {
133 133
 		$found = false;
134 134
 		foreach ($games as $key => $game) {
135
-			if ($this->orderCheckTeamsVal($game, $teams, [], [1,2,3])) {
136
-				$this->moveCalculatedGames($game,$teams);
135
+			if ($this->orderCheckTeamsVal($game, $teams, [], [1, 2, 3])) {
136
+				$this->moveCalculatedGames($game, $teams);
137 137
 				unset($games[$key]);
138 138
 				$found = true;
139 139
 				break;
Please login to merge, or discard this patch.
src/TournamentGenerator/Utilis/Generator.php 1 patch
Spacing   +8 added lines, -8 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
 	}
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 		$discard = [];
121 121
 		shuffle($teams);
122 122
 		$count = count($teams);
123
-		while (count($teams) % $this->inGame !== 0) { $discard[] = array_shift($teams); }
123
+		while (count($teams)%$this->inGame !== 0) { $discard[] = array_shift($teams); }
124 124
 
125 125
 		while (count($teams) > 0) {
126 126
 			$tInGame = [];
127
-			for ($i=0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
127
+			for ($i = 0; $i < $this->inGame; $i++) { $tInGame[] = array_shift($teams); }
128 128
 			$this->group->game($tInGame);
129 129
 		}
130 130
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	public static function circle_genGames2(array $teams = [], \tournamentGenerator\Group $group) {
166 166
 		$bracket = []; // ARRAY OF GAMES
167 167
 
168
-		if (count($teams) % 2 != 0) $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
168
+		if (count($teams)%2 != 0) $teams[] = \TournamentGenerator\Constants::DUMMY_TEAM; // IF NOT EVEN NUMBER OF TEAMS, ADD DUMMY
169 169
 
170 170
 		shuffle($teams); // SHUFFLE TEAMS FOR MORE RANDOMNESS
171 171
 
172
-		for ($i=0; $i < count($teams)-1; $i++) {
172
+		for ($i = 0; $i < count($teams)-1; $i++) {
173 173
 			$bracket = array_merge($bracket, Generator::circle_saveBracket($teams, $group)); // SAVE CURRENT ROUND
174 174
 
175 175
 			$teams = Generator::circle_rotateBracket($teams); // ROTATE TEAMS IN BRACKET
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$bracket = [];
185 185
 
186
-		for ($i=0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
186
+		for ($i = 0; $i < count($teams)/2; $i++) { // GO THROUGH HALF OF THE TEAMS
187 187
 
188 188
 			$home = $teams[$i];
189 189
 			$reverse = array_reverse($teams);
Please login to merge, or discard this patch.
src/TournamentGenerator/Team.php 1 patch
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.
src/TournamentGenerator/Category.php 1 patch
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.
src/TournamentGenerator/Preset/R2G.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
 		$this->splitTeams($round1);
32 32
 
33
-		if (count($this->getTeams()) % 4 == 2) {
33
+		if (count($this->getTeams())%4 == 2) {
34 34
 			$group_top = $round2->group('TOP')->setType(\TournamentGenerator\Constants::ROUND_TWO);
35 35
 
36 36
 			$filter_win_2 = new \TournamentGenerator\TeamFilter('wins', '=', 2, [$group_0_0, $group_top]);
Please login to merge, or discard this patch.
src/TournamentGenerator/Preset/SingleElimination.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 		// CALCULATE BYES
18 18
 		$byes = 0;
19
-		if ( !\TournamentGenerator\isPowerOf2($countTeams) ) {
19
+		if (!\TournamentGenerator\isPowerOf2($countTeams)) {
20 20
 			$nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT));
21 21
 			$byes = $nextPow-$countTeams;
22 22
 		}
@@ -27,17 +27,17 @@  discard block
 block discarded – undo
27 27
 
28 28
 		$previousGroups = [];
29 29
 
30
-		for ($i=1; $i <= (($countTeams+$byes)/2); $i++) {
30
+		for ($i = 1; $i <= (($countTeams+$byes)/2); $i++) {
31 31
 			$g = $startRound->group('Round 1 '.$i)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO);
32 32
 			$previousGroups[] = $g;
33 33
 		}
34 34
 
35 35
 		$this->splitTeams();
36 36
 
37
-		for ($r=2; $r <= $roundsNum; $r++) {
37
+		for ($r = 2; $r <= $roundsNum; $r++) {
38 38
 			$groups = [];
39 39
 			$round = $this->round('Round '.$r);
40
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
40
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
41 41
 				$group = $round->group('Round '.$r.' - '.$g)->setInGame(2)->setType(\TournamentGenerator\Constants::ROUND_TWO);
42 42
 				$groups[] = $group;
43 43
 				array_shift($previousGroups)->progression($group, 0, 1); // PROGRESS FROM GROUP BEFORE
Please login to merge, or discard this patch.
src/TournamentGenerator/TeamFilter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@
 block discarded – undo
43 43
 
44 44
 	private $groups = [];
45 45
 
46
-	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []){
46
+	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []) {
47 47
 		if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) $this->what = strtolower($what);
48 48
 		if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) $this->how = $how;
49 49
 		if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) $this->val = $val;
50
-		$this->groups = array_map(function($a) { return $a->getId(); }, array_filter($groups, function($a) {return ($a instanceof Group);}));
50
+		$this->groups = array_map(function($a) { return $a->getId(); }, array_filter($groups, function($a) {return ($a instanceof Group); }));
51 51
 	}
52 52
 	public function __toString() {
53 53
 		return 'Filter: '.$this->what.' '.($this->what !== 'notprogressed' && $this->what !== 'progressed' ? $this->how.' '.$this->val : '');
Please login to merge, or discard this patch.
src/TournamentGenerator/Round.php 1 patch
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.
src/TournamentGenerator/Game.php 1 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.