@@ -29,9 +29,6 @@ class ScoreTransformer extends TransformerAbstract
2929 'scoreLink.user.country ' ,
3030 ];
3131
32- const TYPE_LEGACY = 'legacy ' ;
33- const TYPE_SOLO = 'solo ' ;
34-
3532 // TODO: user include is deprecated.
3633 const USER_PROFILE_INCLUDES = ['beatmap ' , 'beatmapset ' , 'user ' ];
3734 const USER_PROFILE_INCLUDES_PRELOAD = [
@@ -61,38 +58,19 @@ class ScoreTransformer extends TransformerAbstract
6158 'current_user_attributes ' ,
6259 ];
6360
64- private string $ transformFunction ;
61+ private bool $ legacyFormat ;
6562
66- public static function newSolo (): static
63+ public function __construct (? bool $ legacyFormat = null )
6764 {
68- return new static (static ::TYPE_SOLO );
69- }
70-
71- public function __construct (?string $ type = null )
72- {
73- $ type ??= is_api_request () && api_version () < 20220705
74- ? static ::TYPE_LEGACY
75- : static ::TYPE_SOLO ;
76-
77- switch ($ type ) {
78- case static ::TYPE_LEGACY :
79- $ this ->transformFunction = 'transformLegacy ' ;
80- break ;
81- case static ::TYPE_SOLO :
82- $ this ->transformFunction = 'transformSolo ' ;
83- break ;
84- }
65+ $ this ->legacyFormat = $ legacyFormat ?? (is_api_request () && api_version () < 20220705 );
8566 }
8667
8768 public function transform (LegacyMatch \Score |MultiplayerScoreLink |ScoreModel |SoloScore $ score )
8869 {
89- $ fn = $ this ->transformFunction ;
90-
91- return $ this ->$ fn ($ score );
92- }
70+ if ($ this ->legacyFormat ) {
71+ return $ this ->transformLegacy ($ score );
72+ }
9373
94- public function transformSolo (MultiplayerScoreLink |ScoreModel |SoloScore $ score )
95- {
9674 $ extraAttributes = [];
9775
9876 if ($ score instanceof MultiplayerScoreLink) {
@@ -237,8 +215,7 @@ public function includePosition(MultiplayerScoreLink $scoreLink)
237215 public function includeScoresAround (MultiplayerScoreLink $ scoreLink )
238216 {
239217 static $ limit = 10 ;
240- static $ transformer ;
241- $ transformer ??= static ::newSolo ();
218+ static $ transformer = new static (false );
242219
243220 return $ this ->primitive (array_map (
244221 function ($ item ) use ($ limit , $ transformer ) {
0 commit comments