the browser-facing portion of osu!
at master 45 lines 1.2 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 6declare(strict_types=1); 7 8namespace App\Transformers; 9 10use App\Models\ContestJudgeVote; 11use League\Fractal\Resource\Collection; 12use League\Fractal\Resource\Item; 13use League\Fractal\Resource\Primitive; 14 15class ContestJudgeVoteTransformer extends TransformerAbstract 16{ 17 protected array $availableIncludes = [ 18 'scores', 19 'total_score', 20 'user', 21 ]; 22 23 public function transform(ContestJudgeVote $judgeVote): array 24 { 25 return [ 26 'comment' => $judgeVote->comment, 27 'id' => $judgeVote->getKey(), 28 ]; 29 } 30 31 public function includeScores(ContestJudgeVote $judgeVote): Collection 32 { 33 return $this->collection($judgeVote->scores, new ContestJudgeScoreTransformer()); 34 } 35 36 public function includeTotalScore(ContestJudgeVote $judgeVote): Primitive 37 { 38 return $this->primitive($judgeVote->totalScore()); 39 } 40 41 public function includeUser(ContestJudgeVote $judgeVote): Item 42 { 43 return $this->item($judgeVote->user, new UserCompactTransformer()); 44 } 45}