/**
  * @param \Illuminate\Http\Request $request
  * @param \App\Services\MatchService $service
  * @param $summoner
  * @param $champion
  *
  * @return array|\Ekko\Collection\MatchCollection
  */
 public function championStatus(Request $request, MatchService $service, $summoner, $champion)
 {
     $matchHistory = $service->getMatchesForChampion($summoner, $champion);
     $matches = new MatchCollection();
     $matchHistory->each(function (MatchReference $matchReference) use($service, $matches, $matchHistory) {
         $match = $service->getMatch($matchReference->matchId);
         $match->timeline = null;
         $matches->push($match);
     });
     if ($matches->count() <= 5) {
         return ['status' => 'new', 'data' => $matches->count()];
     }
     $streak = $matches->getStreak($summoner);
     if ($streak['count'] >= 5) {
         return ['status' => 'streak', 'data' => $streak];
     }
     return ['status' => null, 'data' => null];
 }
Example #2
0
 /**
  * @param $summonerId
  * @param $limit
  *
  * @return \Ekko\Collection\MatchCollection
  */
 public function getMatches($summonerId, $limit)
 {
     $that = $this;
     $matchHistory = $this->getMatchHistory($summonerId);
     $matchHistory = $matchHistory->splice(0, $limit);
     $matches = new MatchCollection();
     $matchHistory->each(function (MatchReference $matchReference) use($that, $matches, $summonerId) {
         $match = $that->getMatch($matchReference->matchId);
         $match->timeline = null;
         $matches->push($match);
     });
     return $matches;
 }