src/Api/Game.php
public function trophyInfo() : ?object
    {
        if ($this->game === null) {
            // Kind of a hack here.
            // This endpoint doesn't give exactly the same information as the proper Game endpoint would,
            // But I wasn't able to find a way to get info from the Game endpoint with just a titleId.
            // It works, but I'd rather it be more consistent with the other endpoint.
            $game = $this->get(Trophy::TROPHY_ENDPOINT . 'apps/trophyTitles', [
                'npTitleIds' => $this->titleId,
                'fields' => '@default',
                'npLanguage' => 'en'
            ]);
            
            if (!count($game->apps) || !count($game->apps[0]->trophyTitles)) return null;

            $this->npCommunicationId = $game->apps[0]->trophyTitles[0]->npCommunicationId;

            $data = [
                'npLanguage' => 'en'
            ];

            if ($this->comparing()) {
                $data['comparedUser'] = $this->user()->onlineId();
            }

            $game = $this->get(sprintf(Trophy::TROPHY_ENDPOINT . 'trophyTitles/%s', $this->npCommunicationId), $data);

            if ($game->totalResults !== 1 || !count($game->trophyTitles)) return null;

            $this->game = $game->trophyTitles[0];
        }

        return $this->game;
    }
public function trophyInfo() : ?object
    {
        if ($this->game === null) {
            // Kind of a hack here.
            // This endpoint doesn't give exactly the same information as the proper Game endpoint would,
            // But I wasn't able to find a way to get info from the Game endpoint with just a titleId.
            // It works, but I'd rather it be more consistent with the other endpoint.
            $game = $this->get(Trophy::TROPHY_ENDPOINT . 'apps/trophyTitles', [
                'npTitleIds' => $this->titleId,
                'fields' => '@default',
                'npLanguage' => 'en'
            ]);
            
            if (!count($game->apps) || !count($game->apps[0]->trophyTitles)) return null;

            $this->npCommunicationId = $game->apps[0]->trophyTitles[0]->npCommunicationId;

            $data = [
                'npLanguage' => 'en'
            ];

            if ($this->comparing()) {
                $data['comparedUser'] = $this->user()->onlineId();
            }

            $game = $this->get(sprintf(Trophy::TROPHY_ENDPOINT . 'trophyTitles/%s', $this->npCommunicationId), $data);

            if ($game->totalResults !== 1 || !count($game->trophyTitles)) return null;

            $this->game = $game->trophyTitles[0];
        }

        return $this->game;
    }
public function trophyInfo ( ) : ? object { if ( $ this -> game === null ) { // Kind of a hack here. // This endpoint doesn't give exactly the same information as the proper Game endpoint would, // But I wasn't able to find a way to get info from the Game endpoint with just a titleId. // It works, but I'd rather it be more consistent with the other endpoint. $ game = $ this -> get ( Trophy :: TROPHY_ENDPOINT . 'apps/trophyTitles' , [ 'npTitleIds' => $ this -> titleId , 'fields' => '@default' , 'npLanguage' => 'en' ] ) ; if ( ! count ( $ game -> apps ) || ! count ( $ game -> apps [ 0 ] -> trophyTitles ) ) return null ; $ this -> npCommunicationId = $ game -> apps [ 0 ] -> trophyTitles [ 0 ] -> npCommunicationId ; $ data = [ 'npLanguage' => 'en' ] ; if ( $ this -> comparing ( ) ) { $ data [ 'comparedUser' ] = $ this -> user ( ) -> onlineId ( ) ; } $ game = $ this -> get ( sprintf ( Trophy :: TROPHY_ENDPOINT . 'trophyTitles/%s' , $ this -> npCommunicationId ) , $ data ) ; if ( $ game -> totalResults !== 1 || ! count ( $ game -> trophyTitles ) ) return null ; $ this -> game = $ game -> trophyTitles [ 0 ] ; } return $ this -> game ; }
Gets the trophy information for the Game.

@return object|null
Gets the trophy information for the Game .