| Conditions | 2 |
| Paths | 1 |
| Total Lines | 36 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function collection(EloquentCollection $matches) |
||
| 20 | { |
||
| 21 | $standings = new Collection(); |
||
| 22 | |||
| 23 | $matches = $matches->sortBy('id'); |
||
| 24 | |||
| 25 | $matches->map(function ($match) use ($standings) { |
||
| 26 | |||
| 27 | $pairId = [$match->homeTournamentTeam->id, $match->awayTournamentTeam->id]; |
||
| 28 | sort($pairId); |
||
| 29 | $pairId = implode('-', $pairId); |
||
| 30 | |||
| 31 | $pair = $standings->pull($pairId); |
||
| 32 | |||
| 33 | if (!$pair) { |
||
| 34 | $pair = [ |
||
| 35 | 'id' => $pairId, |
||
| 36 | 'tournamentId' => $match->tournamentId, |
||
| 37 | 'round' => $match->round, |
||
| 38 | 'homeTeamId' => $match->homeTournamentTeam->id, |
||
| 39 | 'homeTeamName' => $match->homeTournamentTeam->team->name, |
||
| 40 | 'awayTeamId' => $match->awayTournamentTeam->id, |
||
| 41 | 'awayTeamName' => $match->awayTournamentTeam->team->name, |
||
| 42 | 'matches' => [] |
||
| 43 | ]; |
||
| 44 | } |
||
| 45 | |||
| 46 | $pair['matches'][] = $match['id']; |
||
| 47 | |||
| 48 | sort($pair['matches']); |
||
| 49 | |||
| 50 | $standings->put($pairId, $pair); |
||
| 51 | }); |
||
| 52 | |||
| 53 | return $standings; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |