@@ -5,25 +5,25 @@ |
||
5 | 5 | |
6 | 6 | class LeagueFixtureGenerator |
7 | 7 | { |
8 | - public static function generate(array $teams) |
|
9 | - { |
|
10 | - $numTeams = count($teams); |
|
11 | - $numRounds = ($numTeams - 1); |
|
12 | - $halfSize = $numTeams / 2; |
|
8 | + public static function generate(array $teams) |
|
9 | + { |
|
10 | + $numTeams = count($teams); |
|
11 | + $numRounds = ($numTeams - 1); |
|
12 | + $halfSize = $numTeams / 2; |
|
13 | 13 | |
14 | - $away = array_splice($teams, $halfSize); |
|
15 | - $home = $teams; |
|
16 | - $rounds = []; |
|
17 | - for ($i = 0; $i < $numRounds ; $i++) { |
|
18 | - for ($j = 0; $j < count($home); $j++) { |
|
19 | - $rounds[$i][$j]["home_team_id"] = $home[$j]['id']; |
|
20 | - $rounds[$i][$j]["away_team_id"] = $away[$j]['id']; |
|
21 | - } |
|
22 | - if (count($home) + count($away) - 1 > 2) { |
|
23 | - array_unshift($away, array_shift(array_splice($home, 1, 1))); |
|
24 | - array_push($home, array_pop($away)); |
|
25 | - } |
|
26 | - } |
|
27 | - return $rounds; |
|
28 | - } |
|
14 | + $away = array_splice($teams, $halfSize); |
|
15 | + $home = $teams; |
|
16 | + $rounds = []; |
|
17 | + for ($i = 0; $i < $numRounds ; $i++) { |
|
18 | + for ($j = 0; $j < count($home); $j++) { |
|
19 | + $rounds[$i][$j]["home_team_id"] = $home[$j]['id']; |
|
20 | + $rounds[$i][$j]["away_team_id"] = $away[$j]['id']; |
|
21 | + } |
|
22 | + if (count($home) + count($away) - 1 > 2) { |
|
23 | + array_unshift($away, array_shift(array_splice($home, 1, 1))); |
|
24 | + array_push($home, array_pop($away)); |
|
25 | + } |
|
26 | + } |
|
27 | + return $rounds; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $away = array_splice($teams, $halfSize); |
15 | 15 | $home = $teams; |
16 | 16 | $rounds = []; |
17 | - for ($i = 0; $i < $numRounds ; $i++) { |
|
17 | + for ($i = 0; $i < $numRounds; $i++) { |
|
18 | 18 | for ($j = 0; $j < count($home); $j++) { |
19 | 19 | $rounds[$i][$j]["home_team_id"] = $home[$j]['id']; |
20 | 20 | $rounds[$i][$j]["away_team_id"] = $away[$j]['id']; |