@@ -21,7 +21,7 @@ discard block |
||
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 |
||
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 |
||
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') { |
@@ -23,8 +23,11 @@ discard block |
||
23 | 23 | |
24 | 24 | public function addRound(Round ...$rounds){ |
25 | 25 | foreach ($rounds as $round) { |
26 | - if ($round instanceof Round) $this->rounds[] = $round; |
|
27 | - else throw new \Exception('Trying to add round which is not an instance of Round class.'); |
|
26 | + if ($round instanceof Round) { |
|
27 | + $this->rounds[] = $round; |
|
28 | + } else { |
|
29 | + throw new \Exception('Trying to add round which is not an instance of Round class.'); |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | return $this; |
30 | 33 | } |
@@ -57,13 +60,15 @@ discard block |
||
57 | 60 | foreach ($teams as $team) { |
58 | 61 | if ($team instanceof Team) { |
59 | 62 | $this->teams[] = $team; |
60 | - } |
|
61 | - elseif (gettype($team) === 'array') { |
|
63 | + } elseif (gettype($team) === 'array') { |
|
62 | 64 | foreach ($team as $team2) { |
63 | - if ($team2 instanceof Team) $this->teams[] = $team2; |
|
65 | + if ($team2 instanceof Team) { |
|
66 | + $this->teams[] = $team2; |
|
67 | + } |
|
64 | 68 | } |
69 | + } else { |
|
70 | + throw new \Exception('Trying to add team which is not an instance of Team class'); |
|
65 | 71 | } |
66 | - else throw new \Exception('Trying to add team which is not an instance of Team class'); |
|
67 | 72 | } |
68 | 73 | return $this; |
69 | 74 | } |
@@ -73,7 +78,9 @@ discard block |
||
73 | 78 | return $t; |
74 | 79 | } |
75 | 80 | public function getTeams() { |
76 | - if (count($this->teams) > 0) return $this->teams; |
|
81 | + if (count($this->teams) > 0) { |
|
82 | + return $this->teams; |
|
83 | + } |
|
77 | 84 | $teams = []; |
78 | 85 | foreach ($this->rounds as $round) { |
79 | 86 | $teams = array_merge($teams, $round->getTeams()); |
@@ -92,7 +99,9 @@ discard block |
||
92 | 99 | |
93 | 100 | public function splitTeams(...$rounds) { |
94 | 101 | |
95 | - if (count($rounds) === 0) $rounds = $this->getRounds(); |
|
102 | + if (count($rounds) === 0) { |
|
103 | + $rounds = $this->getRounds(); |
|
104 | + } |
|
96 | 105 | |
97 | 106 | $teams = $this->getTeams(); |
98 | 107 | shuffle($teams); |
@@ -112,7 +121,9 @@ discard block |
||
112 | 121 | |
113 | 122 | public function genGamesSimulate() { |
114 | 123 | $games = []; |
115 | - if (count($this->rounds) <= 0) throw new \Exception('There are no rounds to simulate games from.'); |
|
124 | + if (count($this->rounds) <= 0) { |
|
125 | + throw new \Exception('There are no rounds to simulate games from.'); |
|
126 | + } |
|
116 | 127 | foreach ($this->rounds as $round) { |
117 | 128 | $games = array_merge($games, $round->genGames()); |
118 | 129 | $round->simulate()->progressBlank()->resetGames(); |
@@ -45,7 +45,7 @@ |
||
45 | 45 | return $this; |
46 | 46 | } |
47 | 47 | |
48 | - public function progressBlank(){ |
|
48 | + public function progressBlank() { |
|
49 | 49 | $teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters); |
50 | 50 | if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
51 | 51 | else $next = $teams; |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addFilter(...$filters) { |
31 | 31 | foreach ($filters as $filter) { |
32 | - if (!$filter instanceof TeamFilter) throw new \Exception('Trying to add filter which is not an instance of TeamFilter.'); |
|
32 | + if (!$filter instanceof TeamFilter) { |
|
33 | + throw new \Exception('Trying to add filter which is not an instance of TeamFilter.'); |
|
34 | + } |
|
33 | 35 | $this->filters[] = $filter; |
34 | 36 | } |
35 | 37 | $this->filters[] = $filter; |
@@ -38,8 +40,11 @@ discard block |
||
38 | 40 | |
39 | 41 | public function progress() { |
40 | 42 | $teams = $this->from->sortTeams($this->filters); |
41 | - if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
42 | - else $next = $teams; |
|
43 | + if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) { |
|
44 | + $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
45 | + } else { |
|
46 | + $next = $teams; |
|
47 | + } |
|
43 | 48 | $this->from->addProgressed($next); |
44 | 49 | $this->to->addTeam($next); |
45 | 50 | return $this; |
@@ -47,8 +52,11 @@ discard block |
||
47 | 52 | |
48 | 53 | public function progressBlank(){ |
49 | 54 | $teams = $this->from->isPlayed() ? $this->from->sortTeams($this->filters) : $this->from->simulate($this->filters); |
50 | - if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
51 | - else $next = $teams; |
|
55 | + if (count($this->filters) === 0 || $this->len !== null || $this->start !== 0) { |
|
56 | + $next = array_splice($teams, $this->start, ($this->len === null ? count($teams) : $this->len)); |
|
57 | + } else { |
|
58 | + $next = $teams; |
|
59 | + } |
|
52 | 60 | $this->from->addProgressed($next); |
53 | 61 | $i = 1; |
54 | 62 | foreach ($next as $team) { |