paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

FeaturedGames tries to use same structure as CurrentGame though the structure is different #130

Open aleksandrd opened 7 years ago

aleksandrd commented 7 years ago

There is a problem with participants in FeaturedGames. According to Riot API FeaturedGames returns Participant object, while CurrentGame uses CurrentGameParticipant. Main difference is that there is no summonerId in the Participant which causes only 1 last participant being returned in the structure when calling $api->featuredGames()->featuredGames().

To fix this: in CurrentGame.php add check that summonerId is set, otherwise don't use associative array, i.e.:

       foreach ($rawParticipants as $pkey=>$value) {
            $participant = new CurrentGameParticipant($value);

            if (!isset($participant->summonerId)) {
                $participants[] = $participant;
            } else {
                $participants[$participant->summonerId] = $participant;
            }

        }
dnlbauer commented 7 years ago

Looks fine. Can you make a pull request from that?

aleksandrd notifications@github.com schrieb am Mo., 9. Jan. 2017, 13:48:

There is a problem with participants in FeaturedGames. According to Riot API FeaturedGames returns Participant object, while CurrentGame uses CurrentGameParticipant. Main difference is that there is no summonerId in the Participant which causes only 1 last participant being returned in the structure when calling $api->featuredGames()->featuredGames().

To fix this: in CurrentGame.php add check that summonerId is set, otherwise don't use associative array, i.e.:

   foreach ($rawParticipants as $pkey=>$value) {
        $participant = new CurrentGameParticipant($value);

        if (!isset($participant->summonerId)) {
            $participants[] = $participant;
        } else {
            $participants[$participant->summonerId] = $participant;
        }

    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/paquettg/leaguewrap/issues/130, or mute the thread https://github.com/notifications/unsubscribe-auth/AEeQ8kvTaOnLYCnIFmhWOHcG5p8rwfpBks5rQiyVgaJpZM4LeOUk .