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;
7
8use App\Models\CountryStatistics;
9
10class CountryStatisticsTransformer extends TransformerAbstract
11{
12 protected array $availableIncludes = ['country'];
13
14 public function transform(CountryStatistics $stat)
15 {
16 return [
17 'code' => $stat->country_code,
18 'active_users' => $stat->user_count,
19 'play_count' => $stat->play_count,
20 'ranked_score' => $stat->ranked_score,
21 'performance' => $stat->performance,
22 ];
23 }
24
25 public function includeCountry(CountryStatistics $stat)
26 {
27 return $stat->country === null
28 ? $this->primitive(null)
29 : $this->item($stat->country, new CountryTransformer());
30 }
31}