-
Notifications
You must be signed in to change notification settings - Fork 0
/
LOL.php
83 lines (65 loc) · 2.11 KB
/
LOL.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace App\Riot;
use Illuminate\Support\Collection;
use PhpParser\ErrorHandler\Collecting;
use RiotAPI\Objects;
use RiotAPI\RiotAPI;
use RiotAPI\Definitions\Region;
class LOL extends RiotAPI
{
/**
* LOL constructor.
* @throws \RiotAPI\Exceptions\SettingsException
*/
public function __construct()
{
parent::__construct([
// Your API key, you can get one at https://developer.riotgames.com/
RiotAPI::SET_KEY => 'RGAPI-f1d1a306-b2df-4410-823c-b6e285024059',
// Target region (you can change it during lifetime of the library instance)
RiotAPI::SET_REGION => Region::LAMERICA_NORTH,
RiotAPI::SET_STATICDATA_LINKING => true,
RiotAPI::SET_CACHE_CALLS => true,
RiotAPI::RESOURCE_THIRD_PARTY_CODE
]);
}
/**
* @param $user
* @param $total
* @return Collection
* @throws \RiotAPI\Exceptions\RequestException
* @throws \RiotAPI\Exceptions\ServerException
* @throws \RiotAPI\Exceptions\ServerLimitException
*/
public function getRanked($user, $total)
{
$games = $this->parseCollection($this->getMatchlistByAccount($user, [440, 420], null, null, null, null, null, $total)->matches);
$details = new Collection();
$games->each(function ($game) use ($details) {
$details->push(
$this->getMatch($game->gameId)
);
});
return $details;
}
public function getParticipantId($participants, $user)
{
foreach ($participants as $participant){
if($user->accountId == $participant->player->accountId or $user->accountId == $participant->player->currentAccountId){
return $participant->participantId;
}
}
}
public function getDataUserGame($game, $pid)
{
foreach ($game->participants as $key => $data){
if($data->participantId == $pid){
return $data;
}
}
}
private function parseCollection($data)
{
return new Collection($data);
}
}