@@ -5,28 +5,28 @@ |
||
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 | - $homeCount = count($home); |
|
19 | - for ($j = 0; $j < $homeCount; $j++) { |
|
20 | - $rounds[$i][$j]["home_team_id"] = $home[$j]['id']; |
|
21 | - $rounds[$i][$j]["away_team_id"] = $away[$j]['id']; |
|
22 | - } |
|
23 | - if (count($home) + count($away) - 1 > 2) { |
|
24 | - $spliced = array_splice($home, 1, 1); |
|
25 | - $shifted = array_shift($spliced); |
|
26 | - array_unshift($away, $shifted); |
|
27 | - array_push($home, array_pop($away)); |
|
28 | - } |
|
29 | - } |
|
30 | - return $rounds; |
|
31 | - } |
|
14 | + $away = array_splice($teams, $halfSize); |
|
15 | + $home = $teams; |
|
16 | + $rounds = []; |
|
17 | + for ($i = 0; $i < $numRounds; $i++) { |
|
18 | + $homeCount = count($home); |
|
19 | + for ($j = 0; $j < $homeCount; $j++) { |
|
20 | + $rounds[$i][$j]["home_team_id"] = $home[$j]['id']; |
|
21 | + $rounds[$i][$j]["away_team_id"] = $away[$j]['id']; |
|
22 | + } |
|
23 | + if (count($home) + count($away) - 1 > 2) { |
|
24 | + $spliced = array_splice($home, 1, 1); |
|
25 | + $shifted = array_shift($spliced); |
|
26 | + array_unshift($away, $shifted); |
|
27 | + array_push($home, array_pop($away)); |
|
28 | + } |
|
29 | + } |
|
30 | + return $rounds; |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |