the browser-facing portion of osu!
at master 51 lines 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Transformers\LegacyMatch; 7 8use App\Models\LegacyMatch\Game; 9use App\Transformers\BeatmapCompactTransformer; 10use App\Transformers\ScoreTransformer; 11use App\Transformers\TransformerAbstract; 12 13class GameTransformer extends TransformerAbstract 14{ 15 protected array $availableIncludes = [ 16 'beatmap', 17 'scores', 18 ]; 19 20 public function transform(Game $game) 21 { 22 return [ 23 'beatmap_id' => $game->beatmap_id, 24 'id' => $game->game_id, 25 'start_time' => $game->start_time_json, 26 'end_time' => $game->end_time_json, 27 'mode' => $game->mode, 28 'mode_int' => $game->play_mode, 29 'scoring_type' => $game->scoring_type, 30 'team_type' => $game->team_type, 31 'mods' => $game->mods, 32 ]; 33 } 34 35 public function includeBeatmap(Game $game) 36 { 37 $beatmap = $game->beatmap; 38 39 if ($beatmap !== null) { 40 return $this->item($beatmap, new BeatmapCompactTransformer()); 41 } 42 } 43 44 public function includeScores(Game $game) 45 { 46 return $this->collection( 47 $game->scores, 48 new ScoreTransformer(ScoreTransformer::TYPE_LEGACY) 49 ); 50 } 51}