Completed
Push — master ( bf2039...b9aa7a )
by Tomáš
02:10
created
src/classes/tournament_presets/class_singleElim.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,7 +27,7 @@  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([
32 32
 				'name' => 'Round 1 - '.$i,
33 33
 				'inGame' => 2,
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
 
39 39
 		$this->splitTeams();
40 40
 
41
-		for ($r=2; $r <= $roundsNum; $r++) {
41
+		for ($r = 2; $r <= $roundsNum; $r++) {
42 42
 			$groups = [];
43 43
 			$round = $this->round('Round '.$r);
44
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
44
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
45 45
 				$group = $round->group([
46 46
 					'name' => 'Round '.$r.' - '.$g,
47 47
 					'inGame' => 2,
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_doubleElim.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		// CALCULATE BYES
20 20
 		$byes = 0;
21 21
 		$nextPow = $countTeams;
22
-		if ( !\TournamentGenerator\isPowerOf2($countTeams) ) {
22
+		if (!\TournamentGenerator\isPowerOf2($countTeams)) {
23 23
 			$nextPow = bindec(str_pad(1, strlen(decbin($countTeams))+1, 0, STR_PAD_RIGHT));
24 24
 			$byes = $nextPow-$countTeams;
25 25
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		$groupIds = [];
39 39
 		$allGroups = [];
40 40
 
41
-		for ($i=1; $i <= $startGroups; $i++) {
41
+		for ($i = 1; $i <= $startGroups; $i++) {
42 42
 			$g = $startRound->group([
43 43
 				'name' => 'Start group - '.$i,
44 44
 				'inGame' => 2,
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		// SPLIT TEAMS EVENLY
53 53
 		$this->splitTeams();
54 54
 
55
-		for ($r=2; $r <= $roundsNum-1; $r++) {
55
+		for ($r = 2; $r <= $roundsNum-1; $r++) {
56 56
 			$groups = [];
57 57
 			$losingGroups = [];
58 58
 			$round = $this->round('Round '.$r);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$losingGroupTeamsCount = count($previousLosingGroups)+count($previousGroups);
64 64
 			$order = 2;
65 65
 			if (\TournamentGenerator\isPowerOf2($losingGroupTeamsCount)) { // IF THE NUMBER OF TEAMS IS A POWER OF 2, GENERATE GROUPS WITHOUT BYES
66
-				for ($g=1; $g <= $losingGroupTeamsCount/2; $g++) {
66
+				for ($g = 1; $g <= $losingGroupTeamsCount/2; $g++) {
67 67
 					$group = $round->group([
68 68
 						'name' => 'Round '.$r.' - loss '.$g,
69 69
 						'inGame' => 2,
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 				$n = (floor(count($previousLosingGroups)/2)+$losingByes);
92 92
 				$byesGroupsNums = [];
93 93
 				$byesProgressed = 0;
94
-				for ($i=0; $i < $losingByes; $i++) {
94
+				for ($i = 0; $i < $losingByes; $i++) {
95 95
 					$byesGroupsNums[] = $n-($i*2);
96 96
 				}
97 97
 				$lastGroup = 0;
98
-				for ($g=1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
98
+				for ($g = 1; $g <= ((count($previousLosingGroups)/2)+$losingByes); $g++) {
99 99
 					$group = $round->group([
100 100
 						'name' => 'Round '.$r.' - loss '.$g,
101 101
 						'inGame' => 2,
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 					}
113 113
 					else {
114 114
 						$previousLosingGroups[$lastGroup]->progression($group, 0, 1); // PROGRESS FROM LOSING GROUP BEFORE
115
-						if (isset($previousLosingGroups[$lastGroup + 1])) $previousLosingGroups[$lastGroup + 1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
115
+						if (isset($previousLosingGroups[$lastGroup+1])) $previousLosingGroups[$lastGroup+1]->progression($group, 0, 1); // PROGREESS FROM LOSING GROUP BEFORE
116 116
 						$lastGroup += 2;
117 117
 					}
118 118
 				}
119 119
 			}
120 120
 			// WINNING SIDE LIKE SINGLE ELIMINATION
121 121
 			$order = 1;
122
-			for ($g=1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
122
+			for ($g = 1; $g <= (($countTeams+$byes)/pow(2, $r)); $g++) {
123 123
 				$group = $round->group([
124 124
 					'name' => 'Round '.$r.' - win '.$g,
125 125
 					'inGame' => 2,
Please login to merge, or discard this patch.
src/classes/class_teamFilter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@
 block discarded – undo
45 45
 
46 46
 	private $groups = [];
47 47
 
48
-	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []){
48
+	function __construct(string $what = 'points', string $how = '>', $val = 0, $groups = []) {
49 49
 		if (in_array(strtolower($what), ['points', 'score', 'wins', 'draws', 'losses', 'second', 'third', 'team', 'notprogressed', 'progressed'])) $this->what = strtolower($what);
50 50
 		if (in_array($how, ['>', '<', '>=', '<=', '=', '!='])) $this->how = $how;
51 51
 		if ((gettype($val) === 'integer' && strtolower($what) !== 'team') || ($val instanceof Team && strtolower($what) === 'team')) $this->val = $val;
52 52
 		foreach ($groups as $group) {
53
-			if ($group instanceof Group) $this->groups[] =  $group->id;
53
+			if ($group instanceof Group) $this->groups[] = $group->id;
54 54
 		}
55 55
 	}
56 56
 	public function __toString() {
Please login to merge, or discard this patch.
src/classes/class_tournament.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private $allowSkip = false;
24 24
 
25
-	function __construct(string $name = ''){
25
+	function __construct(string $name = '') {
26 26
 		$this->name = $name;
27 27
 	}
28 28
 	public function __toString() {
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
 	public function getCategoryWait() {
58 58
 		return $this->expectedCategoryWait;
59 59
 	}
60
-	public function getTournamentTime(){
60
+	public function getTournamentTime() {
61 61
 		$games = count($this->getGames());
62 62
 		return $games*$this->expectedPlay+$games*$this->expectedGameWait+count($this->getRounds())*$this->expectedRoundWait+count($this->getCategories())*$this->expectedCategoryWait;
63 63
 	}
64 64
 
65
-	public function allowSkip(){
65
+	public function allowSkip() {
66 66
 		$this->allowSkip = true;
67 67
 		return $this;
68 68
 	}
69
-	public function disallowSkip(){
69
+	public function disallowSkip() {
70 70
 		$this->allowSkip = false;
71 71
 		return $this;
72 72
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		return $this->allowSkip;
79 79
 	}
80 80
 
81
-	public function addCategory(Category ...$categories){
81
+	public function addCategory(Category ...$categories) {
82 82
 		foreach ($categories as $category) {
83 83
 			if ($category instanceof Category) $this->categories[] = $category;
84 84
 			else throw new \Exception('Trying to add category which is not an instance of the Category class.');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
 	public function addTeam(...$teams) {
121 121
 		foreach ($teams as $team) {
122
-			if ($team instanceof Team)  {
122
+			if ($team instanceof Team) {
123 123
 				$this->teams[] = $team;
124 124
 			}
125 125
 			elseif (gettype($team) === 'array') {
Please login to merge, or discard this patch.
src/classes/class_category.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 		$this->name = $name;
22 22
 	}
23 23
 
24
-	public function addRound(Round ...$rounds){
24
+	public function addRound(Round ...$rounds) {
25 25
 		foreach ($rounds as $round) {
26 26
 			if ($round instanceof Round) $this->rounds[] = $round;
27 27
 			else throw new \Exception('Trying to add round which is not an instance of Round class.');
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 		$this->rounds[] = $r->setSkip($this->allowSkip);
34 34
 		return $r;
35 35
 	}
36
-	public function getRounds(){
36
+	public function getRounds() {
37 37
 		return $this->rounds;
38 38
 	}
39 39
 
40
-	public function allowSkip(){
40
+	public function allowSkip() {
41 41
 		$this->allowSkip = true;
42 42
 		return $this;
43 43
 	}
44
-	public function disallowSkip(){
44
+	public function disallowSkip() {
45 45
 		$this->allowSkip = false;
46 46
 		return $this;
47 47
 	}
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public function addTeam(...$teams) {
57 57
 		foreach ($teams as $team) {
58
-			if ($team instanceof Team)  {
58
+			if ($team instanceof Team) {
59 59
 				$this->teams[] = $team;
60 60
 			}
61 61
 			elseif (gettype($team) === 'array') {
Please login to merge, or discard this patch.
src/classes/class_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->id; }, $this->teams);
72
+	public function getTeamsIds() {
73
+		return array_map(function($a) { return $a->id; }, $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.
src/classes/class_team.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,70 +59,70 @@
 block discarded – undo
59 59
 		return $this;
60 60
 	}
61 61
 
62
-	public function addWin(string $groupId = ''){
62
+	public function addWin(string $groupId = '') {
63 63
 		if (!isset($this->groupResults[$groupId])) throw new \Exception('Group '.$groupId.' is not set for this team ('.$this->name.')');
64 64
 		$this->groupResults[$groupId]['points'] += $this->groupResults[$groupId]['group']->winPoints;
65 65
 		$this->sumPoints += $this->groupResults[$groupId]['group']->winPoints;
66 66
 		$this->groupResults[$groupId]['wins']++;
67 67
 		return $this;
68 68
 	}
69
-	public function removeWin(string $groupId = ''){
69
+	public function removeWin(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 addDraw(string $groupId = ''){
76
+	public function addDraw(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']->drawPoints;
79 79
 		$this->sumPoints += $this->groupResults[$groupId]['group']->drawPoints;
80 80
 		$this->groupResults[$groupId]['draws']++;
81 81
 		return $this;
82 82
 	}
83
-	public function removeDraw(string $groupId = ''){
83
+	public function removeDraw(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']->drawPointsPoints;
86 86
 		$this->sumPoints -= $this->groupResults[$groupId]['group']->drawPoints;
87 87
 		$this->groupResults[$groupId]['draws']--;
88 88
 		return $this;
89 89
 	}
90
-	public function addLoss(string $groupId = ''){
90
+	public function addLoss(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']->lostPoints;
93 93
 		$this->sumPoints += $this->groupResults[$groupId]['group']->lostPoints;
94 94
 		$this->groupResults[$groupId]['losses']++;
95 95
 		return $this;
96 96
 	}
97
-	public function removeLoss(string $groupId = ''){
97
+	public function removeLoss(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 addSecond(string $groupId = ''){
104
+	public function addSecond(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']->secondPoints;
107 107
 		$this->sumPoints += $this->groupResults[$groupId]['group']->secondPoints;
108 108
 		$this->groupResults[$groupId]['second']++;
109 109
 		return $this;
110 110
 	}
111
-	public function removeSecond(string $groupId = ''){
111
+	public function removeSecond(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 addThird(string $groupId = ''){
118
+	public function addThird(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']->thirdPoints;
121 121
 		$this->sumPoints += $this->groupResults[$groupId]['group']->thirdPoints;
122 122
 		$this->groupResults[$groupId]['third']++;
123 123
 		return $this;
124 124
 	}
125
-	public function removeThird(string $groupId = ''){
125
+	public function removeThird(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;
Please login to merge, or discard this patch.
src/classes/tournament_presets/class_2R2G.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 
51 51
 		$this->splitTeams($round1);
52 52
 
53
-		if (count($this->getTeams()) % 4 == 2) {
53
+		if (count($this->getTeams())%4 == 2) {
54 54
 			$group_top = $round2->group([
55 55
 				'name' => 'TOP',
56 56
 				'type' => \TournamentGenerator\TWO_TWO
Please login to merge, or discard this patch.
src/classes/class_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.