Completed
Push — master ( 5d9f44...4b85e8 )
by Tomáš
03:31
created
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/Round.php 1 patch
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.
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/Tournament.php 1 patch
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.
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.