├── .gitignore ├── LICENSE.md ├── README.md ├── composer.json ├── src ├── AsyncRequest.php ├── AsyncRiotAPI.php ├── Constant │ ├── EndPoint.php │ ├── League.php │ ├── Platform.php │ ├── QueueType.php │ ├── Region.php │ └── Season.php ├── Dto │ ├── BaseArrayDto.php │ ├── BaseDto.php │ ├── Champion │ │ ├── ChampionDto.php │ │ ├── ChampionListDto.php │ │ └── FreeChampionIdsDto.php │ ├── ChampionMastery │ │ └── ChampionMasteryDto.php │ ├── DateTime.php │ ├── League │ │ ├── LeagueItemDTO.php │ │ ├── LeagueListDTO.php │ │ ├── LeaguePositionDTO.php │ │ └── MiniSeriesDTO.php │ ├── LolStaticData │ │ ├── Champion │ │ │ ├── BlockDto.php │ │ │ ├── BlockItemDto.php │ │ │ ├── ChampionDto.php │ │ │ ├── ChampionListDto.php │ │ │ ├── ChampionSpellDto.php │ │ │ ├── InfoDto.php │ │ │ ├── LevelTipDto.php │ │ │ ├── PassiveDto.php │ │ │ ├── RecommendedDto.php │ │ │ ├── SkinDto.php │ │ │ └── StatsDto.php │ │ ├── Effect.php │ │ ├── ImageDto.php │ │ ├── Item │ │ │ ├── GoldDto.php │ │ │ ├── GroupDto.php │ │ │ ├── InventoryDataStatsDto.php │ │ │ ├── ItemDto.php │ │ │ ├── ItemListDto.php │ │ │ └── ItemTreeDto.php │ │ ├── Language │ │ │ └── LanguageStringsDto.php │ │ ├── LanguageListDto.php │ │ ├── Map │ │ │ ├── MapDataDto.php │ │ │ └── MapDetailsDto.php │ │ ├── Mastery │ │ │ ├── MasteryDto.php │ │ │ ├── MasteryListDto.php │ │ │ ├── MasteryTreeDto.php │ │ │ ├── MasteryTreeItemDto.php │ │ │ └── MasteryTreeListDto.php │ │ ├── Perk │ │ │ ├── PerkDto.php │ │ │ ├── PerkListDto.php │ │ │ └── PerkPathsDto.php │ │ ├── ProfileIcon │ │ │ ├── ProfileIconDataDto.php │ │ │ └── ProfileIconDetailsDto.php │ │ ├── Realm │ │ │ └── RealmDto.php │ │ ├── Rune │ │ │ ├── MetaDataDto.php │ │ │ ├── RuneDto.php │ │ │ ├── RuneListDto.php │ │ │ └── RuneStatsDto.php │ │ ├── SpellVarsDto.php │ │ ├── SummonerSpell │ │ │ ├── LevelTipDto.php │ │ │ ├── SummonerSpellDto.php │ │ │ └── SummonerSpellListDto.php │ │ └── VersionListDto.php │ ├── Masteries │ │ ├── MasteryDto.php │ │ ├── MasteryPageDto.php │ │ └── MasteryPagesDto.php │ ├── Match │ │ ├── MasteryDto.php │ │ ├── MatchDto.php │ │ ├── MatchReferenceDto.php │ │ ├── MatchlistDto.php │ │ ├── ParticipantDto.php │ │ ├── ParticipantIdentityDto.php │ │ ├── ParticipantStatsDto.php │ │ ├── ParticipantTimelineDto.php │ │ ├── PlayerDto.php │ │ ├── RuneDto.php │ │ ├── TeamBansDto.php │ │ ├── TeamStatsDto.php │ │ └── Timeline │ │ │ ├── MatchEventDto.php │ │ │ ├── MatchFrameDto.php │ │ │ ├── MatchParticipantFrameDto.php │ │ │ ├── MatchPositionDto.php │ │ │ └── MatchTimelineDto.php │ ├── MatchV5 │ │ ├── ChampionStatDto.php │ │ ├── DamageStatDto.php │ │ ├── EventDto.php │ │ ├── FrameDto.php │ │ ├── MatchDetailDto.php │ │ ├── MatchDto.php │ │ ├── MetadataDto.php │ │ ├── MetadataWrapDto.php │ │ ├── ParticipantDto.php │ │ ├── ParticipantFrameDto.php │ │ ├── PerkStat.php │ │ ├── PerkStyle.php │ │ ├── PerkStyleDetail.php │ │ ├── PerksDto.php │ │ ├── PositionDto.php │ │ ├── TeamBanDto.php │ │ ├── TeamDto.php │ │ ├── TeamObjectDetailDto.php │ │ ├── TeamObjectDto.php │ │ ├── TimelineDetailDto.php │ │ ├── TimelineDto.php │ │ └── VictimDamageStatDto.php │ ├── Runes │ │ ├── RunePageDto.php │ │ ├── RunePagesDto.php │ │ └── RuneSlotDto.php │ ├── Spectator │ │ ├── BannedChampion.php │ │ ├── CurrentGameInfo.php │ │ ├── CurrentGameParticipant.php │ │ ├── FeaturedGameInfo.php │ │ ├── FeaturedGames.php │ │ ├── GameCustomizationObject.php │ │ ├── Observer.php │ │ ├── Participant.php │ │ └── Perks.php │ ├── Summoner │ │ └── SummonerDto.php │ └── readme.md ├── EventDispatcher.php ├── Exception │ ├── InvalidParameterException.php │ ├── RequestFailed │ │ ├── Request404Exception.php │ │ ├── Request429LimitExceedException.php │ │ ├── RequestConnectException.php │ │ ├── RequestException.php │ │ ├── RiotAPICallException.php │ │ └── ServerException.php │ ├── RequiredParameterNotFilledException.php │ ├── UnknownException.php │ ├── UnknownQueueIdException.php │ ├── UnknownQueueNameException.php │ ├── UnknownQueueTypeException.php │ └── UnknownSeasonException.php ├── RequestMethod │ ├── Champion │ │ ├── ChampionById.php │ │ ├── ChampionRotations.php │ │ └── Champions.php │ ├── ChampionMastery │ │ └── ChampionMasteryBySummonerId.php │ ├── League │ │ ├── ChallengerLeaguesByQueue.php │ │ ├── GrandMasterLeagues.php │ │ ├── League.php │ │ ├── LeagueEntries.php │ │ ├── LeaguePositions.php │ │ ├── LeaguePositionsBySummoner.php │ │ └── MasterLeaguesByQueue.php │ ├── LolStaticData │ │ ├── Champions.php │ │ ├── Items.php │ │ ├── LanguageStrings.php │ │ ├── Languages.php │ │ ├── Maps.php │ │ ├── Masteries.php │ │ ├── PerkPaths.php │ │ ├── Perks.php │ │ ├── ProfileIcons.php │ │ ├── Realms.php │ │ ├── Runes.php │ │ ├── SummonerSpells.php │ │ └── Versions.php │ ├── Masteries │ │ └── MasteriesBySummoner.php │ ├── Match │ │ ├── MatchById.php │ │ ├── MatchesByAccount.php │ │ └── TimelineById.php │ ├── MatchV5 │ │ ├── MatchById.php │ │ ├── MatchesByPuuid.php │ │ └── TimelineById.php │ ├── RequestMethodAbstract.php │ ├── Runes │ │ └── RunesBySummoner.php │ ├── Spectator │ │ ├── ActiveGameBySummoner.php │ │ └── FeaturedGames.php │ ├── Summoner │ │ ├── SummonerByAccountId.php │ │ ├── SummonerById.php │ │ ├── SummonerByName.php │ │ └── SummonerByPUUID.php │ └── SummonerV3 │ │ └── SummonerById.php ├── Util │ ├── Util.php │ └── endpoints.xlsx └── readme.md └── tests ├── RiotAPIv3Test.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.phar 2 | vendor/ 3 | .idea/ -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2017 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | riotapi-request 2 | =============== 3 | 4 | ## Features 5 | - DTO Support 6 | - Batch calls (async request using guzzlehttp promise) 7 | - You can control concurrency sessions 8 | 9 | ## Installation 10 | ```bash 11 | composer require opgg/riotquest 12 | ``` 13 | 14 | ## Example 15 | ```php 16 | use RiotQuest\Dto\LolStaticData\Champion\ChampionListDto; 17 | use RiotQuest\Dto\Summoner\SummonerDto; 18 | use RiotQuest\RequestMethod; 19 | 20 | function riotApi() { 21 | return new RiotQuest\AsyncRiotAPI('api_key'); 22 | } 23 | 24 | /** @var SummonerDto $summonerDto */ 25 | $summonerDto = $this->riotApi()->call(new RequestMethod\Summoner\SummonerByName(OPServer::getCurrentPlatform(), "kargnas")); 26 | $this->assertTrue($summonerDto instanceof SummonerDto); 27 | $this->assertTrue($summonerDto->revisionDate instanceof \RiotQuest\Dto\DateTime); 28 | 29 | $this->riotApi() 30 | ->add(new RequestMethod\Runes\RunesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id), 31 | function (\RiotQuest\Dto\Runes\RunePagesDto $runePagesDto) use ($summonerDto) { 32 | var_dump($runePagesDto->summonerId === $summonerDto->id); 33 | var_dump(array_first($runePagesDto->pages) instanceof \RiotQuest\Dto\Runes\RunePageDto); 34 | }) 35 | ->add(new RequestMethod\Masteries\MasteriesBySummoner(OPServer::getCurrentPlatform(), $summonerDto->id), 36 | function (\RiotQuest\Dto\Masteries\MasteryPagesDto $masteryPagesDto) use ($summonerDto) { 37 | var_dump($masteryPagesDto->summonerId === $summonerDto->id); 38 | var_dump(array_first($masteryPagesDto->pages) instanceof \RiotQuest\Dto\Masteries\MasteryPageDto); 39 | }) 40 | ->add(new RequestMethod\Match\MatchesByAccount(OPServer::getCurrentPlatform(), $summonerDto->accountId), 41 | function (\RiotQuest\Dto\Match\MatchlistDto $matchlist) { 42 | /** @var \RiotQuest\Dto\Match\MatchDto $match */ 43 | $match = $this->riotApi()->call(new RequestMethod\Match\MatchById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId)); 44 | var_dump($match instanceof \RiotQuest\Dto\Match\MatchDto); 45 | 46 | /** @var \RiotQuest\Dto\Match\Timeline\MatchTimelineDto $timeline */ 47 | $timeline = $this->riotApi()->call(new RequestMethod\Match\TimelineById(OPServer::getCurrentPlatform(), $matchlist->matches[0]->gameId)); 48 | var_dump($timeline instanceof \RiotQuest\Dto\Match\Timeline\MatchTimelineDto); 49 | var_dump($timeline->frames[0] instanceof \RiotQuest\Dto\Match\Timeline\MatchFrameDto); 50 | }) 51 | ->exec(); 52 | ``` 53 | 54 | ## TODO 55 | - Rate limit 56 | - PSR-6 57 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "opgg/riotquest", 3 | "type": "library", 4 | "description": "RiotQuest, PHP RiotAPI client library that focused on multi request from OP.GG", 5 | "keywords": ["http", "rest", "guzzle", "curl", "client", "HTTP client"], 6 | "homepage": "http://op.gg/", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Sangrak Choi", 11 | "email": "kars@kargn.as", 12 | "homepage": "http://kargn.as" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.5", 17 | "guzzlehttp/guzzle": ">=6.0", 18 | "netresearch/jsonmapper": ">=1.1.0" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit": "^4.0 || ^5.0" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "RiotQuest\\": "src/" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/AsyncRequest.php: -------------------------------------------------------------------------------- 1 | getCode()}, Request URI: {$exception->getRequestURI()})"; 58 | if ($shortBody = $exception->getResponseShortBody()) { 59 | $message .= "\r\nBody: {$shortBody})"; 60 | } 61 | 62 | throw $exception; 63 | }; 64 | } 65 | 66 | $this->requestMethod = $requestMethod; 67 | $this->request = $request; 68 | $this->callbackDone = $cb1; 69 | $this->callbackFail = $cb2; 70 | } 71 | 72 | public function onDone(Response $response) { 73 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_SUCCESS__BEFORE_CALLBACK, [$response, $this]); 74 | 75 | // Dto 로 바꿔서 던져준다. 76 | $cb = $this->callbackDone; 77 | $res = $cb($this->requestMethod->mapping($response)); 78 | 79 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_SUCCESS__AFTER_CALLBACK, [$this]); 80 | return $res; 81 | } 82 | 83 | public function onFail(GuzzleException $guzzleException, $debugInfo) { 84 | $exception = RiotAPICallException::ByGuzzleException($guzzleException, $debugInfo); 85 | 86 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_FAIL__BEFORE_CALLBACK, [$exception]); 87 | 88 | $cb = $this->callbackFail; 89 | $res = $cb($exception); 90 | 91 | // 위의 cb(콜백) 호출로 인해 아래 EventDispatcher 및 return 까지 도달하진 않음 92 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_FAIL__AFTER_CALLBACK, [$this]); 93 | return $res; 94 | } 95 | 96 | /** 97 | * @param Client $client 98 | * 99 | * @return \GuzzleHttp\Promise\PromiseInterface 100 | */ 101 | public function getPromise(Client $client) { 102 | return $client->sendAsync($this->request, [ 103 | RequestOptions::ON_STATS => function (TransferStats $stats) { 104 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_ONSTATS, [$stats]); 105 | } 106 | ]); 107 | } 108 | } -------------------------------------------------------------------------------- /src/AsyncRiotAPI.php: -------------------------------------------------------------------------------- 1 | PHP 의 특성) 25 | * add 메소드를 통해서 리퀘스트를 추가할 수 있으며, 각 리퀘스트가 종료될 때 마다 onDone 혹은 onFail 이 실행된다. 26 | * 27 | * Class AsyncRiotAPI 28 | * @package RiotQuest 29 | */ 30 | class AsyncRiotAPI 31 | { 32 | const RETRY_UNLIMITED = -1; 33 | 34 | // Flags for each objects. 35 | public $isRespectRateLimitHeaders = true; 36 | public $concurrency = 30; 37 | public $retryLimits = 5; 38 | public $requestTimeout = 10.0; 39 | public $userAgentString = "OP.GG API Client"; 40 | 41 | // Member Variables 42 | protected $apiKey; 43 | 44 | /** @var bool The super important flag for nested callbacks with `add` and `exec` method. This will make throw if user call `add` after `exec` before requests are ended. */ 45 | private $isExecuting = false; 46 | 47 | /** @var AsyncRequest[] */ 48 | protected $requests = []; 49 | 50 | function __construct($apiKey) { 51 | $this->apiKey = $apiKey; 52 | } 53 | 54 | /** 55 | * @param $tried 56 | * @param GuzzleException|null $exception 57 | * 58 | * @return bool 59 | */ 60 | protected function shouldRetry($tried, GuzzleException $exception = null) { 61 | if ($this->retryLimits !== static::RETRY_UNLIMITED && $tried >= $this->retryLimits) { 62 | // NEED TO WARNING 63 | return false; 64 | } 65 | 66 | if ($exception instanceof ConnectException) { 67 | return true; 68 | } 69 | 70 | if ($exception instanceof RequestException) { 71 | 72 | $response = $exception->getResponse(); 73 | 74 | if ($response === null) { 75 | return true; 76 | } 77 | 78 | if ($response) { 79 | if ($response->getStatusCode() >= 500) { 80 | return true; 81 | } 82 | 83 | if ($response->getStatusCode() === 429) { 84 | EventDispatcher::fire(EventDispatcher::EVENT_EXCEED_RATELIMIT, [ 85 | $response, 86 | $exception->getRequest(), 87 | ]); 88 | return true; 89 | } 90 | } 91 | } 92 | 93 | return false; 94 | } 95 | 96 | public function getNewGuzzleClient() { 97 | return new Client([ 98 | 'timeout' => $this->requestTimeout 99 | ]); 100 | } 101 | 102 | ///////////////////////////// 103 | /// Sync Call 104 | /** 105 | * @param RequestMethodAbstract $requestMethod 106 | * 107 | * @return BaseDto|BaseArrayDto 108 | */ 109 | public function call(RequestMethodAbstract $requestMethod) { 110 | $result = null; 111 | 112 | $this->add($requestMethod, function ($dto) use (&$result) { 113 | $result = $dto; 114 | }, function (RiotAPICallException $exception) { 115 | throw $exception; 116 | })->exec(); 117 | 118 | return $result; 119 | } 120 | /// 121 | ///////////////////////////// 122 | 123 | ///////////////////////////// 124 | /// Async Call 125 | /** 126 | * 비동기 콜에 새로운 Request 추가 127 | * 128 | * @param RequestMethodAbstract $requestMethod 129 | * @param callable $onDone 성공시 실행된다. 130 | * @param callable|null $onFail 실패시 실행된다. HTTP Status 200 이 아닐 때 발생한다. 131 | * RequestFailedException will be thrown If you do not make specific this callback. 132 | * 133 | * @return $this 134 | */ 135 | public function add(RequestMethodAbstract $requestMethod, callable $onDone, callable $onFail = null) { 136 | // Exec 작동중일때는 add 못하게 한다. 버그 방지. 137 | if ($this->isExecuting === true) { 138 | throw new UnknownException("You can't add the request when this instance executing. Please make new instance of " . get_class($this) . "."); 139 | } 140 | 141 | $guzzleRequest = $requestMethod->getRequest(); 142 | $guzzleRequest = $guzzleRequest->withAddedHeader("X-Riot-Token", $this->apiKey); 143 | $guzzleRequest = $guzzleRequest->withAddedHeader("User-Agent", $this->userAgentString); 144 | 145 | $this->requests[] = new AsyncRequest($requestMethod, $guzzleRequest, $onDone, $onFail); 146 | return $this; 147 | } 148 | 149 | /** 150 | * 비동기콜 한방에 모두 시작. 모든 콜 완료시 return void. 151 | * 152 | * @return void 153 | */ 154 | public function exec() { 155 | $client = $this->getNewGuzzleClient(); 156 | $this->isExecuting = true; 157 | 158 | // 실패한 리퀘스트는 다시 재시도한다. 159 | while(sizeof($this->requests) > 0) { 160 | $pool = new Pool($client, 161 | array_map(function (AsyncRequest $asyncRequest) use ($client) { 162 | // 익명함수 만들어야됨: 이해 안되면 guzzlehttp 문서 참조 163 | return (function () use ($asyncRequest, $client) { 164 | // 재시도인 경우에만 이벤트 호출 165 | if ($asyncRequest->tried >= 1) { 166 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST_RETRIED__BEFORE, [ 167 | $asyncRequest->tried + 1, 168 | $asyncRequest 169 | ]); 170 | } 171 | 172 | // TODO: MAKE YOU CAN THROW REQUEST EXCEPTION IN THIS EVENT. 173 | EventDispatcher::fire(EventDispatcher::EVENT_REQUEST__BEFORE, [ 174 | $asyncRequest 175 | ]); 176 | 177 | return $asyncRequest->getPromise($client); 178 | }); 179 | }, $this->requests), [ 180 | 'concurrency' => $this->concurrency, 181 | 'fulfilled' => function (Response $response, $index) { 182 | $this->requests[$index]->tried++; 183 | $this->requests[$index]->markFinished = true; 184 | $this->requests[$index]->onDone($response); 185 | }, 186 | 'rejected' => function (GuzzleException $exception, $index) { 187 | $this->requests[$index]->tried++; 188 | 189 | // 재시도 할 필요 없으면, 실패 리퀘스트를 날려준다. 190 | if (!$this->shouldRetry($this->requests[$index]->tried, $exception)) { 191 | 192 | $ApiKeyLastWord = explode("-", $this->apiKey)[count(explode("-", $this->apiKey))-1]; 193 | $debugInfo = $ApiKeyLastWord; 194 | 195 | $this->requests[$index]->markFinished = true; 196 | $this->requests[$index]->onFail($exception, $debugInfo); 197 | } 198 | } 199 | ]); 200 | 201 | $promise = $pool->promise(); 202 | $promise->wait(); 203 | 204 | $this->clearFinishedRequests(); 205 | } 206 | 207 | $this->clear(); 208 | $this->isExecuting = false; 209 | } 210 | 211 | /** 212 | * 동시 리퀘스트 제한 수를 수정한다. 1을 걸면 동기 리퀘스트나 다름 없다. 30으로 하면 동시에 30개 리퀘스트를 Async 로 처리한다. 213 | * 214 | * @param $limit 215 | * 216 | * @return $this 217 | */ 218 | public function setConcurrency($limit) { 219 | $this->concurrency = $limit; 220 | return $this; 221 | } 222 | 223 | protected function clearFinishedRequests() { 224 | $this->requests = array_filter($this->requests, function (AsyncRequest $request) { 225 | return !$request->markFinished; 226 | }); 227 | } 228 | 229 | public function clear() { 230 | $this->requests = []; 231 | } 232 | /// 233 | ///////////////////////// 234 | } -------------------------------------------------------------------------------- /src/Constant/EndPoint.php: -------------------------------------------------------------------------------- 1 | self::$CONTINENT_AMERICA, 96 | self::ASIA => self::$CONTINENT_ASIA, 97 | self::EUROPE => self::$CONTINENT_EUROPE, 98 | self::SEA => self::$CONTINENT_SEA, 99 | ]; 100 | } 101 | 102 | public static function findContinentByRegion($region) { 103 | foreach (static::ContinentMap() as $continent => $regions) { 104 | if (in_array($region, $regions)) { 105 | return $continent; 106 | } 107 | } 108 | return null; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Constant/Season.php: -------------------------------------------------------------------------------- 1 | "PRESEASON3", 41 | static::SEASON3 => "SEASON3", 42 | static::PRESEASON2014 => "PRESEASON2014", 43 | static::SEASON2014 => "SEASON2014", 44 | static::PRESEASON2015 => "PRESEASON2015", 45 | static::SEASON2015 => "SEASON2015", 46 | static::PRESEASON2016 => "PRESEASON2016", 47 | static::SEASON2016 => "SEASON2016", 48 | static::PRESEASON2017 => "PRESEASON2017", 49 | static::SEASON2017 => "SEASON2017", 50 | static::PRESEASON2018 => "PRESEASON2018", 51 | static::SEASON2018 => "SEASON2018", 52 | static::PRESEASON2019 => "PRESEASON2019", 53 | static::SEASON2019 => "SEASON2019", 54 | static::PRESEASON2020 => "PRESEASON2020", 55 | static::SEASON2020 => "SEASON2020", 56 | static::PRESEASON2021 => "PRESEASON2021", 57 | static::SEASON2021 => "SEASON2021", 58 | static::PRESEASON2022 => "PRESEASON2022", 59 | static::SEASON2022 => "SEASON2022", 60 | static::PRESEASON2023 => "PRESEASON2023", 61 | static::SEASON2023 => "SEASON2023", 62 | ]; 63 | } 64 | 65 | public static function getSeasonName($seasonId) { 66 | $map = static::Map(); 67 | 68 | if (isset($map[$seasonId])) { 69 | return $map[$seasonId]; 70 | } 71 | 72 | throw new UnknownSeasonException("'" . $seasonId . "' is unknown season id."); 73 | } 74 | } -------------------------------------------------------------------------------- /src/Dto/BaseDto.php: -------------------------------------------------------------------------------- 1 | json_encode, 32 | * which is a value of any type other than a resource. 33 | * @since 5.4.0 34 | */ 35 | function jsonSerialize() { 36 | $list = []; 37 | foreach ($this as $key => $val) { 38 | if ($this->isHideAttribute($key)) continue; 39 | if ($this->isHideNullValue === false && $val === null) continue; 40 | 41 | $list[$key] = $val; 42 | } 43 | 44 | return $list; 45 | } 46 | 47 | /** 48 | * @return array 49 | */ 50 | public function toArray() { 51 | return json_decode($this->toJson(), true); 52 | } 53 | 54 | public function toJson($options = 0) { 55 | return json_encode($this, $options); 56 | } 57 | } -------------------------------------------------------------------------------- /src/Dto/Champion/ChampionDto.php: -------------------------------------------------------------------------------- 1 | isZero = true; 19 | } else { 20 | parent::__construct('@' . substr($timestamp, 0, 10)); 21 | $this->setTimezone(new \DateTimeZone('Asia/Seoul')); 22 | } 23 | } 24 | 25 | public function isZero() { 26 | return $this->isZero; 27 | } 28 | 29 | /** 30 | * 0이면 null 을 리턴. 31 | * 32 | * @param string $format 33 | * 34 | * @return null|string 35 | */ 36 | public function format($format) { 37 | if ($this->isZero) { 38 | return null; 39 | } else { 40 | return parent::format($format); 41 | } 42 | } 43 | 44 | /** 45 | * Specify data which should be serialized to JSON 46 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php 47 | * @return mixed data which can be serialized by json_encode, 48 | * which is a value of any type other than a resource. 49 | * @since 5.4.0 50 | */ 51 | function jsonSerialize() { 52 | return $this->isZero() ? 0 : $this->getTimestamp(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/Dto/League/LeagueItemDTO.php: -------------------------------------------------------------------------------- 1 | FlatArmorModPerLevel 16 | * rFlatArmorPenetrationMod => FlatArmorPenetrationMod 17 | * rFlatArmorPenetrationModPerLevel => FlatArmorPenetrationModPerLevel 18 | * rFlatCritChanceModPerLevel => FlatCritChanceModPerLevel 19 | * rFlatCritDamageModPerLevel => FlatCritDamageModPerLevel 20 | * rFlatDodgeMod => FlatDodgeMod 21 | * rFlatDodgeModPerLevel => FlatDodgeModPerLevel 22 | * rFlatEnergyModPerLevel => FlatEnergyModPerLevel 23 | * rFlatEnergyRegenModPerLevel => FlatEnergyRegenModPerLevel 24 | * rFlatGoldPer10Mod => FlatGoldPer10Mod 25 | * rFlatHPModPerLevel => FlatHPModPerLevel 26 | * rFlatHPRegenModPerLevel => FlatHPRegenModPerLevel 27 | * rFlatMagicDamageModPerLevel => FlatMagicDamageModPerLevel 28 | * rFlatMagicPenetrationMod => FlatMagicPenetrationMod 29 | * rFlatMagicPenetrationModPerLevel => FlatMagicPenetrationModPerLevel 30 | * rFlatMovementSpeedModPerLevel => FlatMovementSpeedModPerLevel 31 | * rFlatMPModPerLevel => FlatMPModPerLevel 32 | * rFlatMPRegenModPerLevel => FlatMPRegenModPerLevel 33 | * rFlatPhysicalDamageModPerLevel => FlatPhysicalDamageModPerLevel 34 | * rFlatSpellBlockModPerLevel => FlatSpellBlockModPerLevel 35 | * rFlatTimeDeadMod => FlatTimeDeadMod 36 | * rFlatTimeDeadModPerLevel => FlatTimeDeadModPerLevel 37 | * rPercentArmorPenetrationMod => PercentArmorPenetrationMod 38 | * rPercentArmorPenetrationModPerLevel => PercentArmorPenetrationModPerLevel 39 | * rPercentAttackSpeedModPerLevel => PercentAttackSpeedModPerLevel 40 | * rPercentCooldownMod => PercentCooldownMod 41 | * rPercentCooldownModPerLevel => PercentCooldownModPerLevel 42 | * rPercentMagicPenetrationMod => PercentMagicPenetrationMod 43 | * rPercentMagicPenetrationModPerLevel => PercentMagicPenetrationModPerLevel 44 | * rPercentMovementSpeedModPerLevel => PercentMovementSpeedModPerLevel 45 | * rPercentTimeDeadMod => PercentTimeDeadMod 46 | * rPercentTimeDeadModPerLevel => PercentTimeDeadModPerLevel 47 | * 48 | * Class RuneStatsDto 49 | * @package RiotQuest\Dto\LolStaticData\Rune 50 | */ 51 | class RuneStatsDto extends BaseDto 52 | { 53 | /** @var double */ 54 | public $PercentTimeDeadModPerLevel; 55 | /** @var double */ 56 | public $PercentArmorPenetrationModPerLevel; 57 | /** @var double */ 58 | public $PercentCritDamageMod; 59 | /** @var double */ 60 | public $PercentSpellBlockMod; 61 | /** @var double */ 62 | public $PercentHPRegenMod; 63 | /** @var double */ 64 | public $PercentMovementSpeedMod; 65 | /** @var double */ 66 | public $FlatSpellBlockMod; 67 | /** @var double */ 68 | public $FlatEnergyRegenModPerLevel; 69 | /** @var double */ 70 | public $FlatEnergyPoolMod; 71 | /** @var double */ 72 | public $FlatMagicPenetrationModPerLevel; 73 | /** @var double */ 74 | public $PercentLifeStealMod; 75 | /** @var double */ 76 | public $FlatMPPoolMod; 77 | /** @var double */ 78 | public $PercentCooldownMod; 79 | /** @var double */ 80 | public $PercentMagicPenetrationMod; 81 | /** @var double */ 82 | public $FlatArmorPenetrationModPerLevel; 83 | /** @var double */ 84 | public $FlatMovementSpeedMod; 85 | /** @var double */ 86 | public $FlatTimeDeadModPerLevel; 87 | /** @var double */ 88 | public $FlatArmorModPerLevel; 89 | /** @var double */ 90 | public $PercentAttackSpeedMod; 91 | /** @var double */ 92 | public $FlatDodgeModPerLevel; 93 | /** @var double */ 94 | public $PercentMagicDamageMod; 95 | /** @var double */ 96 | public $PercentBlockMod; 97 | /** @var double */ 98 | public $FlatDodgeMod; 99 | /** @var double */ 100 | public $FlatEnergyRegenMod; 101 | /** @var double */ 102 | public $FlatHPModPerLevel; 103 | /** @var double */ 104 | public $PercentAttackSpeedModPerLevel; 105 | /** @var double */ 106 | public $PercentSpellVampMod; 107 | /** @var double */ 108 | public $FlatMPRegenMod; 109 | /** @var double */ 110 | public $PercentHPPoolMod; 111 | /** @var double */ 112 | public $PercentDodgeMod; 113 | /** @var double */ 114 | public $FlatAttackSpeedMod; 115 | /** @var double */ 116 | public $FlatArmorMod; 117 | /** @var double */ 118 | public $FlatMagicDamageModPerLevel; 119 | /** @var double */ 120 | public $FlatHPRegenMod; 121 | /** @var double */ 122 | public $PercentPhysicalDamageMod; 123 | /** @var double */ 124 | public $FlatCritChanceModPerLevel; 125 | /** @var double */ 126 | public $FlatSpellBlockModPerLevel; 127 | /** @var double */ 128 | public $PercentTimeDeadMod; 129 | /** @var double */ 130 | public $FlatBlockMod; 131 | /** @var double */ 132 | public $PercentMPPoolMod; 133 | /** @var double */ 134 | public $FlatMagicDamageMod; 135 | /** @var double */ 136 | public $PercentMPRegenMod; 137 | /** @var double */ 138 | public $PercentMovementSpeedModPerLevel; 139 | /** @var double */ 140 | public $PercentCooldownModPerLevel; 141 | /** @var double */ 142 | public $FlatMPModPerLevel; 143 | /** @var double */ 144 | public $FlatEnergyModPerLevel; 145 | /** @var double */ 146 | public $FlatPhysicalDamageMod; 147 | /** @var double */ 148 | public $FlatHPRegenModPerLevel; 149 | /** @var double */ 150 | public $FlatCritDamageMod; 151 | /** @var double */ 152 | public $PercentArmorMod; 153 | /** @var double */ 154 | public $FlatMagicPenetrationMod; 155 | /** @var double */ 156 | public $PercentCritChanceMod; 157 | /** @var double */ 158 | public $FlatPhysicalDamageModPerLevel; 159 | /** @var double */ 160 | public $PercentArmorPenetrationMod; 161 | /** @var double */ 162 | public $PercentEXPBonus; 163 | /** @var double */ 164 | public $FlatMPRegenModPerLevel; 165 | /** @var double */ 166 | public $PercentMagicPenetrationModPerLevel; 167 | /** @var double */ 168 | public $FlatTimeDeadMod; 169 | /** @var double */ 170 | public $FlatMovementSpeedModPerLevel; 171 | /** @var double */ 172 | public $FlatGoldPer10Mod; 173 | /** @var double */ 174 | public $FlatArmorPenetrationMod; 175 | /** @var double */ 176 | public $FlatCritDamageModPerLevel; 177 | /** @var double */ 178 | public $FlatHPPoolMod; 179 | /** @var double */ 180 | public $FlatCritChanceMod; 181 | /** @var double */ 182 | public $FlatEXPBonus; 183 | } -------------------------------------------------------------------------------- /src/Dto/LolStaticData/SpellVarsDto.php: -------------------------------------------------------------------------------- 1 | masteryId); 25 | } 26 | 27 | /** 28 | * @param $masteryId 29 | * 30 | * @return bool 31 | */ 32 | public static function isKeystoneMasteryById($masteryId) { 33 | $keystoneMasteryIdList = [ 34 | 6161, 6162, 6164, 35 | 6361, 6362, 6363, 36 | 6261, 6262, 6263 37 | ]; 38 | if (@in_array((int)$masteryId, $keystoneMasteryIdList, true)) { 39 | return true; 40 | } 41 | return false; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Dto/Match/MatchDto.php: -------------------------------------------------------------------------------- 1 | New 17 | * "matchCreation": 1454028303878, => "gameCreation": 1454028303878, 18 | * "matchDuration": 2176, => "gameDuration": 2176, 19 | * "matchId": 2275813950, => "gameId": 2275813950, 20 | * "matchMode": "CLASSIC", => "gameMode": "CLASSIC", 21 | * "matchType": "MATCHED_GAME", => "gameType": "MATCHED_GAME", 22 | * "matchVersion": "6.2.0.238", => "gameVersion": "6.2.0.238", 23 | * 24 | * Class MatchDto 25 | * @package RiotQuest\Dto\Match 26 | */ 27 | class MatchDto extends BaseDto 28 | { 29 | 30 | /** @var int */ 31 | public $seasonId; 32 | 33 | /** @var int */ 34 | public $queueId; 35 | 36 | /** @var double */ 37 | public $gameId; 38 | 39 | /** @var ParticipantIdentityDto[] */ 40 | public $participantIdentities; 41 | 42 | /** @var string */ 43 | public $gameVersion; 44 | 45 | /** @var string */ 46 | public $platformId; 47 | 48 | /** @var string */ 49 | public $gameMode; 50 | 51 | /** @var int */ 52 | public $mapId; 53 | 54 | /** @var string */ 55 | public $gameType; 56 | 57 | /** @var TeamStatsDto[] */ 58 | public $teams; 59 | 60 | /** @var ParticipantDto[] */ 61 | public $participants; 62 | 63 | /** @var double */ 64 | public $gameDuration; 65 | 66 | /** @var \RiotQuest\Dto\DateTime */ 67 | public $gameCreation; 68 | 69 | /** 70 | * There is no flag for remake in riotapi. 71 | * 72 | * @return bool 73 | */ 74 | public function isRemake() { 75 | return $this->queueId != QueueType::UNKNOWN_2000 && $this->gameDuration < 210; 76 | } 77 | 78 | /** 79 | * @return QueueType 80 | */ 81 | public function getQueueType() { 82 | try { 83 | return QueueType::ById($this->queueId); 84 | } catch (UnknownQueueIdException $e) { 85 | return new QueueType($this->queueId, $this->queueId); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/Dto/Match/MatchReferenceDto.php: -------------------------------------------------------------------------------- 1 | queue); 37 | } catch (UnknownQueueIdException $e) { 38 | return new QueueType($this->queue, $this->queue); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Dto/Match/MatchlistDto.php: -------------------------------------------------------------------------------- 1 | masteries) === 0) { 41 | return null; 42 | } 43 | foreach ($this->masteries as $mastery) { 44 | if ($mastery->isKeystoneMastery()) { 45 | return $mastery; 46 | } 47 | } 48 | 49 | return null; 50 | } 51 | } -------------------------------------------------------------------------------- /src/Dto/Match/ParticipantIdentityDto.php: -------------------------------------------------------------------------------- 1 | New 15 | * "championsKilled": 2, => "kills": 2, 16 | * "numDeaths": 2, => "deaths": 2, 17 | * "physicalDamageDealtToChampions": 341, => "physicalDamageDealt": 2, 18 | * "magicDamageDealtPlayer" => "magicDamageDealt" 19 | * "physicalDamageDealtToChampions": 341, => "physicalDamageDealt": 2, 20 | * "magicDamageTaken": 11090, => "magicalDamageTaken": 11090, 21 | * "minionsKilled": 136, => "totalMinionsKilled": 136, 22 | * "towerKills": 0, => "turretKills": 0, 23 | * "winner": false => "win": false 24 | * 25 | * Class ParticipantStatsDto 26 | * @package RiotQuest\Dto\Match 27 | */ 28 | class ParticipantStatsDto extends BaseDto 29 | { 30 | /** @var double */ 31 | public $physicalDamageDealt; 32 | /** @var int */ 33 | public $neutralMinionsKilledTeamJungle; 34 | /** @var double */ 35 | public $magicDamageDealt; 36 | /** @var int */ 37 | public $totalPlayerScore; 38 | /** @var int */ 39 | public $deaths; 40 | /** @var boolean */ 41 | public $win; 42 | /** @var int */ 43 | public $neutralMinionsKilledEnemyJungle; 44 | /** @var int */ 45 | public $altarsCaptured; 46 | /** @var int */ 47 | public $largestCriticalStrike; 48 | /** @var double */ 49 | public $totalDamageDealt; 50 | /** @var double */ 51 | public $magicDamageDealtToChampions; 52 | /** @var int */ 53 | public $visionWardsBoughtInGame; 54 | /** @var double */ 55 | public $damageDealtToObjectives; 56 | /** @var int */ 57 | public $largestKillingSpree; 58 | /** @var int */ 59 | public $item1; 60 | /** @var int */ 61 | public $quadraKills; 62 | /** @var int */ 63 | public $teamObjective; 64 | /** @var int */ 65 | public $totalTimeCrowdControlDealt; 66 | /** @var int */ 67 | public $doubleestTimeSpentLiving; 68 | /** @var int */ 69 | public $wardsKilled; 70 | /** @var boolean */ 71 | public $firstTowerAssist; 72 | /** @var boolean */ 73 | public $firstTowerKill; 74 | /** @var int */ 75 | public $item2; 76 | /** @var int */ 77 | public $item3; 78 | /** @var int */ 79 | public $item0; 80 | /** @var boolean */ 81 | public $firstBloodAssist; 82 | /** @var double */ 83 | public $visionScore; 84 | /** @var int */ 85 | public $wardsPlaced; 86 | /** @var int */ 87 | public $item4; 88 | /** @var int */ 89 | public $item5; 90 | /** @var int */ 91 | public $item6; 92 | /** @var int */ 93 | public $turretKills; 94 | /** @var int */ 95 | public $tripleKills; 96 | /** @var double */ 97 | public $damageSelfMitigated; 98 | /** @var int */ 99 | public $champLevel; 100 | /** @var int */ 101 | public $nodeNeutralizeAssist; 102 | /** @var boolean */ 103 | public $firstInhibitorKill; 104 | /** @var int */ 105 | public $goldEarned; 106 | /** @var double */ 107 | public $magicalDamageTaken; 108 | /** @var int */ 109 | public $kills; 110 | /** @var int */ 111 | public $doubleKills; 112 | /** @var int */ 113 | public $nodeCaptureAssist; 114 | /** @var double */ 115 | public $trueDamageTaken; 116 | /** @var int */ 117 | public $nodeNeutralize; 118 | /** @var boolean */ 119 | public $firstInhibitorAssist; 120 | /** @var int */ 121 | public $assists; 122 | /** @var int */ 123 | public $unrealKills; 124 | /** @var int */ 125 | public $neutralMinionsKilled; 126 | /** @var int */ 127 | public $objectivePlayerScore; 128 | /** @var int */ 129 | public $combatPlayerScore; 130 | /** @var double */ 131 | public $damageDealtToTurrets; 132 | /** @var int */ 133 | public $altarsNeutralized; 134 | /** @var double */ 135 | public $physicalDamageDealtToChampions; 136 | /** @var int */ 137 | public $goldSpent; 138 | /** @var double */ 139 | public $trueDamageDealt; 140 | /** @var double */ 141 | public $trueDamageDealtToChampions; 142 | /** @var int */ 143 | public $participantId; 144 | /** @var int */ 145 | public $pentaKills; 146 | /** @var double */ 147 | public $totalHeal; 148 | /** @var int */ 149 | public $totalMinionsKilled; 150 | /** @var boolean */ 151 | public $firstBloodKill; 152 | /** @var int */ 153 | public $nodeCapture; 154 | /** @var int */ 155 | public $largestMultiKill; 156 | /** @var int */ 157 | public $sightWardsBoughtInGame; 158 | /** @var double */ 159 | public $totalDamageDealtToChampions; 160 | /** @var int */ 161 | public $totalUnitsHealed; 162 | /** @var int */ 163 | public $inhibitorKills; 164 | /** @var int */ 165 | public $totalScoreRank; 166 | /** @var double */ 167 | public $totalDamageTaken; 168 | /** @var int */ 169 | public $killingSprees; 170 | /** @var double */ 171 | public $timeCCingOthers; 172 | /** @var double */ 173 | public $physicalDamageTaken; 174 | 175 | /** @var int */ 176 | public $perk0; 177 | /** @var int */ 178 | public $perk0Var1; 179 | /** @var int */ 180 | public $perk0Var2; 181 | /** @var int */ 182 | public $perk0Var3; 183 | 184 | /** @var int */ 185 | public $perk1; 186 | /** @var int */ 187 | public $perk1Var1; 188 | /** @var int */ 189 | public $perk1Var2; 190 | /** @var int */ 191 | public $perk1Var3; 192 | 193 | /** @var int */ 194 | public $perk2; 195 | /** @var int */ 196 | public $perk2Var1; 197 | /** @var int */ 198 | public $perk2Var2; 199 | /** @var int */ 200 | public $perk2Var3; 201 | 202 | /** @var int */ 203 | public $perk3; 204 | /** @var int */ 205 | public $perk3Var1; 206 | /** @var int */ 207 | public $perk3Var2; 208 | /** @var int */ 209 | public $perk3Var3; 210 | 211 | /** @var int */ 212 | public $perk4; 213 | /** @var int */ 214 | public $perk4Var1; 215 | /** @var int */ 216 | public $perk4Var2; 217 | /** @var int */ 218 | public $perk4Var3; 219 | 220 | /** @var int */ 221 | public $perk5; 222 | /** @var int */ 223 | public $perk5Var1; 224 | /** @var int */ 225 | public $perk5Var2; 226 | /** @var int */ 227 | public $perk5Var3; 228 | 229 | /** @var int */ 230 | public $statPerk0; 231 | /** @var int */ 232 | public $statPerk1; 233 | /** @var int */ 234 | public $statPerk2; 235 | 236 | /** @var int */ 237 | public $perkPrimaryStyle; 238 | /** @var int */ 239 | public $perkSubStyle; 240 | 241 | /** @var int */ 242 | public $longestTimeSpentLiving; 243 | } -------------------------------------------------------------------------------- /src/Dto/Match/ParticipantTimelineDto.php: -------------------------------------------------------------------------------- 1 | New 15 | * creepsPerMinDeltas.zeroToTen: 5.6 => creepsPerMinDeltas.0-10: 5.6 16 | * creepsPerMinDeltas.tenToTwenty: 3.5 => creepsPerMinDeltas.10-20: 3.5 17 | * creepsPerMinDeltas.twentyToThirty: 3.2 => creepsPerMinDeltas.20-30: 3.2 18 | * creepsPerMinDeltas.thirtyToEnd: 2.6 => creepsPerMinDeltas.30-end: 2.6 19 | * 20 | * Class ParticipantTimelineDto 21 | * @package RiotQuest\Dto\Match 22 | */ 23 | class ParticipantTimelineDto extends BaseDto 24 | { 25 | /** @var string */ 26 | public $lane; 27 | /** @var int */ 28 | public $participantId; 29 | /** @var array */ 30 | public $csDiffPerMinDeltas; 31 | /** @var array */ 32 | public $goldPerMinDeltas; 33 | /** @var array */ 34 | public $xpDiffPerMinDeltas; 35 | /** @var array */ 36 | public $creepsPerMinDeltas; 37 | /** @var array */ 38 | public $xpPerMinDeltas; 39 | /** @var string */ 40 | public $role; 41 | /** @var array */ 42 | public $damageTakenDiffPerMinDeltas; 43 | /** @var array */ 44 | public $damageTakenPerMinDeltas; 45 | } -------------------------------------------------------------------------------- /src/Dto/Match/PlayerDto.php: -------------------------------------------------------------------------------- 1 | win === 'Win'; 50 | } 51 | 52 | public function isLose() { 53 | return $this->win === 'Fail'; 54 | } 55 | } -------------------------------------------------------------------------------- /src/Dto/Match/Timeline/MatchEventDto.php: -------------------------------------------------------------------------------- 1 | New 15 | * "eventType": "ITEM_PURCHASED" => "type": "ITEM_PURCHASED" 16 | * "itemAfter": 3340 => "afterId": 3340 17 | * "itemBefore": 3340 => "beforeId": 3340 18 | * 19 | * Class MatchEventDto 20 | * @package RiotQuest\Dto\Match\Timeline 21 | */ 22 | class MatchEventDto extends BaseDto 23 | { 24 | const TYPE_CHAMPION_KILL = "CHAMPION_KILL"; 25 | const TYPE_WARD_PLACED = "WARD_PLACED"; 26 | const TYPE_WARD_KILL = "WARD_KILL"; 27 | const TYPE_BUILDING_KILL = "BUILDING_KILL"; 28 | const TYPE_ELITE_MONSTER_KILL = "ELITE_MONSTER_KILL"; 29 | const TYPE_ITEM_PURCHASED = "ITEM_PURCHASED"; 30 | const TYPE_ITEM_SOLD = "ITEM_SOLD"; 31 | const TYPE_ITEM_DESTROYED = "ITEM_DESTROYED"; 32 | const TYPE_ITEM_UNDO = "ITEM_UNDO"; 33 | const TYPE_SKILL_LEVEL_UP = "SKILL_LEVEL_UP"; 34 | const TYPE_ASCENDED_EVENT = "ASCENDED_EVENT"; 35 | const TYPE_CAPTURE_POINT = "CAPTURE_POINT"; 36 | const TYPE_PORO_KING_SUMMON = "PORO_KING_SUMMON"; 37 | 38 | /** @var string */ 39 | public $eventType; 40 | /** @var string */ 41 | public $towerType; 42 | /** @var int */ 43 | public $teamId; 44 | /** @var string */ 45 | public $ascendedType; 46 | /** @var int */ 47 | public $killerId; 48 | /** @var string */ 49 | public $levelUpType; 50 | /** @var string */ 51 | public $pointCaptured; 52 | /** @var int[] */ 53 | public $assistingParticipantIds; 54 | /** @var string */ 55 | public $wardType; 56 | /** @var string */ 57 | public $monsterType; 58 | /** @var string (Legal values: CHAMPION_KILL, WARD_PLACED, WARD_KILL, BUILDING_KILL, ELITE_MONSTER_KILL, ITEM_PURCHASED, ITEM_SOLD, ITEM_DESTROYED, ITEM_UNDO, SKILL_LEVEL_UP, ASCENDED_EVENT, CAPTURE_POINT, PORO_KING_SUMMON) */ 59 | public $type; 60 | /** @var int */ 61 | public $skillSlot; 62 | /** @var int */ 63 | public $victimId; 64 | /** @var \RiotQuest\Dto\DateTime */ 65 | public $timestamp; 66 | /** @var int */ 67 | public $afterId; 68 | /** @var string */ 69 | public $monsterSubType; 70 | /** @var string */ 71 | public $laneType; 72 | /** @var int */ 73 | public $itemId; 74 | /** @var int */ 75 | public $participantId; 76 | /** @var string */ 77 | public $buildingType; 78 | /** @var int */ 79 | public $creatorId; 80 | /** @var MatchPositionDto */ 81 | public $position; 82 | /** @var int */ 83 | public $beforeId; 84 | } -------------------------------------------------------------------------------- /src/Dto/Match/Timeline/MatchFrameDto.php: -------------------------------------------------------------------------------- 1 | gameDuration = $gameDuration; 52 | } 53 | 54 | /** 55 | * [CAUTION] the unit of gameDuration has been changed. 56 | * (v4)seconds -> (v5)milliseconds 57 | * 58 | * @return int 59 | */ 60 | public function getGameDurationOrigin() { 61 | return $this->gameDuration; 62 | } 63 | 64 | /** 65 | * Check the unit of the property, convert it if necessary, and return it. 66 | * convert milliseconds to seconds 67 | * 68 | * @return int|float 69 | */ 70 | public function getGameDurationSecond() { 71 | if ($this->gameStartTimestamp && $this->gameEndTimestamp) { 72 | return (int)($this->gameEndTimestamp->getTimestamp() - $this->gameStartTimestamp->getTimestamp()); 73 | } 74 | 75 | return (int)($this->gameDuration / 1000); 76 | } 77 | 78 | /** 79 | * There is no flag for remake in riotapi. 80 | * 81 | * @return bool 82 | */ 83 | public function isRemake() { 84 | return !$this->getQueueType()->isTutorial() && $this->getGameDurationSecond() < 210; 85 | } 86 | 87 | /** 88 | * @return QueueType 89 | */ 90 | public function getQueueType() { 91 | try { 92 | return QueueType::ById($this->queueId); 93 | } catch (UnknownQueueIdException $e) { 94 | return new QueueType($this->queueId, $this->queueId); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /src/Dto/MatchV5/MatchDto.php: -------------------------------------------------------------------------------- 1 | matchId)[0]; 18 | } 19 | 20 | public function getGameId() { 21 | return explode('_', $this->matchId)[1]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Dto/MatchV5/MetadataWrapDto.php: -------------------------------------------------------------------------------- 1 | puuid === 'BOT'); 222 | } 223 | } -------------------------------------------------------------------------------- /src/Dto/MatchV5/ParticipantFrameDto.php: -------------------------------------------------------------------------------- 1 | gameQueueConfigId); 43 | } catch (UnknownQueueIdException $e) { 44 | return new QueueType($this->gameQueueConfigId, $this->gameQueueConfigId); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Dto/Spectator/CurrentGameParticipant.php: -------------------------------------------------------------------------------- 1 | gameQueueConfigId); 43 | } catch (UnknownQueueIdException $e) { 44 | return new QueueType($this->gameQueueConfigId, $this->gameQueueConfigId); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Dto/Spectator/FeaturedGames.php: -------------------------------------------------------------------------------- 1 | σ 62 | return trim(str_replace([ 63 | ' ', '/', "\t", "\r", "\n", // Riot policy 64 | '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '.', ',', '<', '>', '?', '\'', ';', '[', ']', '{', '}', '`', '\\' // invalid strings 65 | ], '', mb_convert_encoding(mb_strtolower($summonerName), "UTF-8"))); 66 | } 67 | 68 | /** 69 | * @return string 70 | */ 71 | public function getInternalName() { 72 | return static::InternalName($this->name); 73 | } 74 | } -------------------------------------------------------------------------------- /src/Dto/readme.md: -------------------------------------------------------------------------------- 1 | ## JsonMapper PHP Doc 2 | | RiotAPI Type | PHPDoc | | 3 | |----------------------------|--------------------------|----------------| 4 | | Map[string, `anything`] | array | 원래는 `anything`[] 으로 하면 되지만, Key 에 '-', '_', ' ' 등이 포함되어 있을 경우 자동 탈락되는 문제가 발생한다. 5 | | Map[int, `anything`] | array | -------------------------------------------------------------------------------- /src/EventDispatcher.php: -------------------------------------------------------------------------------- 1 | getCode()); 25 | 26 | $this->exception = $guzzleException; 27 | } 28 | 29 | public function getResponseBody() { 30 | if (!($response = $this->exception->getResponse())) { 31 | return null; 32 | } 33 | 34 | return $response->getBody(); 35 | } 36 | 37 | public function getResponseShortBody() { 38 | if ($this->exception instanceof RequestException) { 39 | return mb_strimwidth($this->getResponseBody(), 0, 100, '...'); 40 | } 41 | 42 | return null; 43 | } 44 | 45 | /** 46 | * @return string 47 | */ 48 | public function getRequestURI() { 49 | return (string) $this->exception->getRequest()->getUri(); 50 | } 51 | 52 | /** 53 | * @param GuzzleException $exception 54 | * 55 | * @param $debugInfo 56 | * @return RiotAPICallException 57 | */ 58 | public static function ByGuzzleException(GuzzleException $exception, $debugInfo) { 59 | 60 | if ($exception instanceof ConnectException) { 61 | return new RequestConnectException($exception->getMessage(), $exception); 62 | } elseif ($exception instanceof RequestException) { 63 | $response = $exception->getResponse(); 64 | 65 | if ($response === null) { 66 | return new \RiotQuest\Exception\RequestFailed\RequestException($exception->getMessage(), $exception); 67 | } 68 | 69 | if (400 <= $response->getStatusCode() && $response->getStatusCode() <= 499) { 70 | switch($response->getStatusCode()) { 71 | case 404: 72 | return new Request404Exception($exception->getMessage(), $exception); 73 | break; 74 | 75 | case 429: 76 | return new Request429LimitExceedException($exception->getMessage(), $exception); 77 | break; 78 | 79 | // 403 에러는 확인이 필요해서 디버깅용 메세지를 추가함 80 | case 403: 81 | return new \RiotQuest\Exception\RequestFailed\RequestException($exception->getMessage()." / ".$debugInfo, $exception); 82 | break; 83 | 84 | default: 85 | return new \RiotQuest\Exception\RequestFailed\RequestException($exception->getMessage(), $exception); 86 | } 87 | } elseif ($response->getStatusCode() >= 500) { 88 | return new ServerException($exception->getMessage(), $exception); 89 | } else { 90 | return new \RiotQuest\Exception\RequestFailed\RequestException($exception->getMessage(), $exception); 91 | } 92 | } else { 93 | return new RiotAPICallException($exception->getMessage(), $exception); 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /src/Exception/RequestFailed/ServerException.php: -------------------------------------------------------------------------------- 1 | getCode()}] " . $this->getMessage(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Exception/UnknownQueueIdException.php: -------------------------------------------------------------------------------- 1 | championId = $championId; 28 | } 29 | 30 | public function getRequest() { 31 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 32 | $uri = str_replace("{id}", $this->championId, $uri); 33 | 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $json = \GuzzleHttp\json_decode($response->getBody()); 39 | 40 | $mapper = new JsonMapper(); 41 | 42 | return $mapper->map($json, new ChampionDto()); 43 | } 44 | } -------------------------------------------------------------------------------- /src/RequestMethod/Champion/ChampionRotations.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 17 | 18 | return $this->getPsr7Request('GET', $uri); 19 | } 20 | 21 | public function mapping(Response $response) { 22 | $json = \GuzzleHttp\json_decode($response->getBody()); 23 | 24 | $mapper = new JsonMapper(); 25 | 26 | return $mapper->map($json, new FreeChampionIdsDto()); 27 | } 28 | } -------------------------------------------------------------------------------- /src/RequestMethod/Champion/Champions.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 26 | 27 | $query = static::buildParams([ 28 | 'freeToPlay' => $this->freeToPlay 29 | ]); 30 | 31 | if (strlen($query) > 0) { 32 | $uri .= "?{$query}"; 33 | } 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $json = \GuzzleHttp\json_decode($response->getBody()); 39 | 40 | $mapper = new JsonMapper(); 41 | 42 | return $mapper->map($json, new ChampionListDto()); 43 | } 44 | } -------------------------------------------------------------------------------- /src/RequestMethod/ChampionMastery/ChampionMasteryBySummonerId.php: -------------------------------------------------------------------------------- 1 | summonerId = $summonerId; 35 | } 36 | 37 | 38 | /** 39 | * @return \GuzzleHttp\Psr7\Request 40 | */ 41 | public function getRequest() { 42 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 43 | $uri = str_replace("{encryptedSummonerId}", $this->summonerId, $uri); 44 | 45 | return $this->getPsr7Request('GET', $uri); 46 | } 47 | 48 | /** 49 | * @param \GuzzleHttp\Psr7\Response $response 50 | * 51 | * @return mixed|\RiotQuest\Dto\BaseDto|\RiotQuest\Dto\BaseArrayDto|array 52 | */ 53 | public function mapping(Response $response) { 54 | $json = \GuzzleHttp\json_decode($response->getBody()); 55 | 56 | $mapper = new JsonMapper(); 57 | 58 | $items = []; 59 | foreach ($json as $key => $val) { 60 | $items[] = $mapper->map($val, new ChampionMasteryDto()); 61 | } 62 | return $items; 63 | } 64 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/ChallengerLeaguesByQueue.php: -------------------------------------------------------------------------------- 1 | queue = $queue; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{queue}", $this->queue, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | return $mapper->map($json, new LeagueListDTO()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/GrandMasterLeagues.php: -------------------------------------------------------------------------------- 1 | queue = $queue; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{queue}", $this->queue, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | return $mapper->map($json, new LeagueListDTO()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/League.php: -------------------------------------------------------------------------------- 1 | leagueId = $leagueId; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{leagueId}", $this->leagueId, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | return $mapper->map($json, new LeagueListDTO()); 43 | } 44 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/LeagueEntries.php: -------------------------------------------------------------------------------- 1 | queue = $queue; 22 | $this->tier = $tier; 23 | $this->division = $division; 24 | $this->page = $page; 25 | } 26 | 27 | public function getRequest() { 28 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 29 | 30 | $uri = str_replace('{queue}', $this->queue, $uri); 31 | $uri = str_replace('{tier}', $this->tier, $uri); 32 | $uri = str_replace('{division}', $this->division, $uri); 33 | $uri .= "?page={$this->page}"; 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | $items = []; 44 | foreach ($json as $key => $val) { 45 | $items[] = $mapper->map($val, new LeaguePositionDTO()); 46 | } 47 | return $items; 48 | } 49 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/LeaguePositions.php: -------------------------------------------------------------------------------- 1 | positionalQueue = $positionalQueue; 28 | $this->tier = $tier; 29 | $this->division = $division; 30 | $this->position = $position; 31 | $this->page = $page; 32 | } 33 | 34 | public function getRequest() { 35 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 36 | 37 | $uri = str_replace('{positionalQueue}', $this->positionalQueue, $uri); 38 | $uri = str_replace('{tier}', $this->tier, $uri); 39 | $uri = str_replace('{division}', $this->division, $uri); 40 | $uri = str_replace('{position}', $this->position, $uri); 41 | $uri = str_replace('{page}', $this->page, $uri); 42 | 43 | return $this->getPsr7Request('GET', $uri); 44 | } 45 | 46 | public function mapping(Response $response) { 47 | $json = \GuzzleHttp\json_decode($response->getBody()); 48 | 49 | $mapper = new JsonMapper(); 50 | 51 | $items = []; 52 | foreach ($json as $key => $val) { 53 | $items[] = $mapper->map($val, new LeaguePositionDTO()); 54 | } 55 | return $items; 56 | } 57 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/LeaguePositionsBySummoner.php: -------------------------------------------------------------------------------- 1 | encryptedSummonerId = $encryptedSummonerId; 32 | } 33 | 34 | public function getRequest() { 35 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 36 | $uri = str_replace("{encryptedSummonerId}", $this->encryptedSummonerId, $uri); 37 | 38 | return $this->getPsr7Request('GET', $uri); 39 | } 40 | 41 | public function mapping(Response $response) { 42 | $json = \GuzzleHttp\json_decode($response->getBody()); 43 | 44 | $mapper = new JsonMapper(); 45 | 46 | $items = []; 47 | foreach ($json as $key => $val) { 48 | $items[] = $mapper->map($val, new LeaguePositionDTO()); 49 | } 50 | return $items; 51 | } 52 | } -------------------------------------------------------------------------------- /src/RequestMethod/League/MasterLeaguesByQueue.php: -------------------------------------------------------------------------------- 1 | queue = $queue; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{queue}", $this->queue, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | return $mapper->map($json, new LeagueListDTO()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Champions.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/cdn/{$this->version}/data/{$this->locale}" . $this->path; 27 | 28 | return $this->getPsr7Request('GET', $uri); 29 | } 30 | 31 | public function mapping(Response $response) { 32 | $json = \GuzzleHttp\json_decode($response->getBody(), true); 33 | 34 | $mapper = new JsonMapper(); 35 | $mapper->bEnforceMapType = false; 36 | 37 | $championList = new ChampionListDto(); 38 | $championList->version = $json['version']; 39 | $championList->type = $json['type']; 40 | $championList->format = $json['format']; 41 | 42 | $championList->keys = []; 43 | $championList->data = []; 44 | 45 | foreach ($json['data'] as $champKey => $champRow) { 46 | $jsonChampRow = json_decode(json_encode($champRow), true); 47 | 48 | foreach ($jsonChampRow['spells'] as &$spellRow) { 49 | // fix diff between ddragon and static-data API 50 | foreach ($spellRow['vars'] as &$varRow) { 51 | if (!is_array($varRow['coeff'])) { 52 | $varRow['coeff'] = [(double) $varRow['coeff']]; 53 | } 54 | } 55 | foreach ($spellRow['effectBurn'] as &$effectBurnRow) { 56 | if ($effectBurnRow == null) { 57 | $effectBurnRow = ""; 58 | } 59 | } 60 | $spellRow['key'] = $spellRow['id']; 61 | unset($spellRow['id']); 62 | 63 | $spellRow['sanitizedDescription'] = $spellRow['description']; 64 | $spellRow['sanitizedTooltip'] = $spellRow['tooltip']; 65 | } 66 | 67 | /** @var ChampionDto $championDto */ 68 | $championDto = $mapper->map($jsonChampRow, new ChampionDto()); 69 | if ($championDto != null) { 70 | $championDto->id = (int) $champRow['key']; 71 | $championDto->key = $champKey; 72 | } 73 | 74 | $championList->keys[$championDto->id] = $championDto->key; 75 | $championList->data[$championDto->id] = $championDto; 76 | } 77 | 78 | return $championList; 79 | } 80 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Items.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/cdn/{$this->version}/data/{$this->locale}" . $this->path; 29 | 30 | return $this->getPsr7Request('GET', $uri); 31 | } 32 | 33 | public function mapping(Response $response) { 34 | $json = \GuzzleHttp\json_decode($response->getBody(), true); 35 | 36 | $itemList = new ItemListDto(); 37 | $itemList->version = $json['version']; 38 | $itemList->type = $json['type']; 39 | $itemList->data = []; 40 | $itemList->tree = []; 41 | $itemList->groups = []; 42 | 43 | $mapper = new JsonMapper(); 44 | $mapper->bEnforceMapType = false; 45 | 46 | foreach ($json['data'] as $itemKey => $itemRow) { 47 | $jsonItemRow = json_decode(json_encode($itemRow), true); 48 | 49 | /** @var ItemDto $itemDto */ 50 | $itemDto = $mapper->map($jsonItemRow, new ItemDto()); 51 | if ($itemDto != null) { 52 | $itemDto->id = (int) $itemKey; 53 | $itemDto->sanitizedDescription = $itemDto->description; 54 | $itemList->data[$itemKey] = $itemDto; 55 | } 56 | } 57 | 58 | foreach ($json['tree'] as $treeRow) { 59 | $jsonTreeRow = json_decode(json_encode($treeRow), true); 60 | 61 | /** @var ItemTreeDto $treeDto */ 62 | $treeDto = $mapper->map($jsonTreeRow, new ItemTreeDto()); 63 | $itemList->tree[] = $treeDto; 64 | } 65 | 66 | foreach ($json['groups'] as $groupRow) { 67 | $jsonGroupRow = json_decode(json_encode($groupRow), true); 68 | 69 | $jsonGroupRow['key'] = $jsonGroupRow['id']; 70 | unset($jsonGroupRow['id']); 71 | 72 | /** @var GroupDto $groupDto */ 73 | $groupDto = $mapper->map($jsonGroupRow, new GroupDto()); 74 | $itemList->groups[] = $groupDto; 75 | } 76 | 77 | return $itemList; 78 | } 79 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/LanguageStrings.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 27 | 28 | $query = static::buildParams([ 29 | 'locale' => $this->locale, 30 | 'version' => $this->version 31 | ]); 32 | 33 | if (strlen($query) > 0) { 34 | $uri .= "?{$query}"; 35 | } 36 | return $this->getPsr7Request('GET', $uri); 37 | } 38 | 39 | public function mapping(Response $response) { 40 | $json = \GuzzleHttp\json_decode($response->getBody()); 41 | 42 | $mapper = new JsonMapper(); 43 | return $mapper->map($json, new LanguageStringsDto()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Languages.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 27 | 28 | return $this->getPsr7Request('GET', $uri); 29 | } 30 | 31 | public function mapping(Response $response) { 32 | $json = \GuzzleHttp\json_decode($response->getBody()); 33 | 34 | $mapper = new JsonMapper(); 35 | $mapper->bEnforceMapType = false; 36 | return $mapper->map($json, new LanguageListDto()); 37 | } 38 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Maps.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 27 | 28 | $query = static::buildParams([ 29 | 'locale' => $this->locale, 30 | 'version' => $this->version 31 | ]); 32 | 33 | if (strlen($query) > 0) { 34 | $uri .= "?{$query}"; 35 | } 36 | return $this->getPsr7Request('GET', $uri); 37 | } 38 | 39 | public function mapping(Response $response) { 40 | $json = \GuzzleHttp\json_decode($response->getBody()); 41 | 42 | $mapper = new JsonMapper(); 43 | return $mapper->map($json, new MapDataDto()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Masteries.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 30 | 31 | $query = static::buildParams([ 32 | 'locale' => $this->locale, 33 | 'version' => $this->version, 34 | 'tags' => $this->tags 35 | ]); 36 | 37 | if (strlen($query) > 0) { 38 | $uri .= "?{$query}"; 39 | } 40 | return $this->getPsr7Request('GET', $uri); 41 | } 42 | 43 | public function mapping(Response $response) { 44 | $json = \GuzzleHttp\json_decode($response->getBody()); 45 | 46 | $mapper = new JsonMapper(); 47 | return $mapper->map($json, new MasteryListDto()); 48 | } 49 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/PerkPaths.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/cdn/{$this->version}/data/{$this->locale}" . $this->path; 19 | 20 | return $this->getPsr7Request('GET', $uri); 21 | } 22 | 23 | public function mapping(Response $response) { 24 | $json = \GuzzleHttp\json_decode($response->getBody(), true); 25 | 26 | $perkPaths = new PerkPathsDto(); 27 | $perkPaths->version = $this->version; 28 | $perkPaths->data = []; 29 | 30 | foreach ($json as $jsonRow) { 31 | $ppId = $jsonRow['id']; 32 | $ppData = []; 33 | foreach ($jsonRow['slots'] as $jsonSlot) { 34 | $runeIds = []; 35 | foreach ($jsonSlot['runes'] as $jsonRune) { 36 | $runeId = $jsonRune['id']; 37 | $runeIds[] = $runeId; 38 | } 39 | $ppData[] = $runeIds; 40 | } 41 | 42 | $perkPaths->data[] = [ 43 | $ppId => $ppData 44 | ]; 45 | } 46 | return $perkPaths; 47 | } 48 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Perks.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/cdn/{$this->version}/data/{$this->locale}" . $this->path; 21 | 22 | return $this->getPsr7Request('GET', $uri); 23 | } 24 | 25 | public function mapping(Response $response) { 26 | $json = \GuzzleHttp\json_decode($response->getBody(), true); 27 | 28 | $perkList = new PerkListDto(); 29 | $perkList->version = $this->version; 30 | $perkList->data = []; 31 | 32 | $mapper = new JsonMapper(); 33 | foreach ($json as $styleRow) { 34 | $slotsArr = $styleRow['slots']; 35 | foreach ($slotsArr as $slotRow) { 36 | $runesArr = $slotRow['runes']; 37 | foreach ($runesArr as $runeRow) { 38 | $jsonRuneRow = json_decode(json_encode($runeRow)); 39 | $perkDto = $mapper->map($jsonRuneRow, new PerkDto()); 40 | if ($perkDto !== null) { 41 | $perkList->data[] = $perkDto; 42 | } 43 | } 44 | 45 | } 46 | 47 | } 48 | return $perkList; 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/ProfileIcons.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 27 | 28 | $query = static::buildParams([ 29 | 'locale' => $this->locale, 30 | 'version' => $this->version 31 | ]); 32 | 33 | if (strlen($query) > 0) { 34 | $uri .= "?{$query}"; 35 | } 36 | return $this->getPsr7Request('GET', $uri); 37 | } 38 | 39 | public function mapping(Response $response) { 40 | $json = \GuzzleHttp\json_decode($response->getBody()); 41 | 42 | $mapper = new JsonMapper(); 43 | return $mapper->map($json, new ProfileIconDataDto()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Realms.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 23 | 24 | return $this->getPsr7Request('GET', $uri); 25 | } 26 | 27 | public function mapping(Response $response) { 28 | $json = \GuzzleHttp\json_decode($response->getBody()); 29 | 30 | $mapper = new JsonMapper(); 31 | return $mapper->map($json, new RealmDto()); 32 | } 33 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Runes.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 30 | 31 | $query = static::buildParams([ 32 | 'locale' => $this->locale, 33 | 'version' => $this->version, 34 | 'tags' => $this->tags, 35 | ]); 36 | 37 | if (strlen($query) > 0) { 38 | $uri .= "?{$query}"; 39 | } 40 | return $this->getPsr7Request('GET', $uri); 41 | } 42 | 43 | public function mapping(Response $response) { 44 | $json = \GuzzleHttp\json_decode($response->getBody()); 45 | 46 | $mapper = new JsonMapper(); 47 | return $mapper->map($json, new RuneListDto()); 48 | } 49 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/SummonerSpells.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/cdn/{$this->version}/data/{$this->locale}" . $this->path; 27 | 28 | return $this->getPsr7Request('GET', $uri); 29 | } 30 | 31 | public function mapping(Response $response) { 32 | $json = \GuzzleHttp\json_decode($response->getBody(), true); 33 | 34 | $spellList = new SummonerSpellListDto(); 35 | $spellList->version = $json['version']; 36 | $spellList->type = $json['type']; 37 | $spellList->data = []; 38 | 39 | $mapper = new JsonMapper(); 40 | $mapper->bEnforceMapType = false; 41 | 42 | foreach ($json['data'] as $spellKey => $spellRow) { 43 | 44 | $jsonSpellRow = json_decode(json_encode($spellRow), true); 45 | 46 | // fix diff between ddragon and static-data API 47 | foreach ($jsonSpellRow['vars'] as &$varRow) { 48 | if (!is_array($varRow['coeff'])) { 49 | $varRow['coeff'] = [(int) $varRow['coeff']]; 50 | } 51 | } 52 | foreach ($jsonSpellRow['effectBurn'] as &$effectBurnRow) { 53 | if ($effectBurnRow == null) { 54 | $effectBurnRow = ""; 55 | } 56 | } 57 | $jsonSpellRow['sanitizedDescription'] = $jsonSpellRow['description']; 58 | $jsonSpellRow['sanitizedTooltip'] = $jsonSpellRow['tooltip']; 59 | 60 | /** @var SummonerSpellDto $spellDto */ 61 | $spellDto = $mapper->map($jsonSpellRow, new SummonerSpellDto()); 62 | if ($spellDto != null) { 63 | // fix diff between ddragon and static-data API 64 | $spellDto->id = (int) $spellDto->key; 65 | $spellDto->key = $spellKey; 66 | $spellList->data[$spellDto->id] = $spellDto; 67 | } 68 | } 69 | 70 | return $spellList; 71 | } 72 | } -------------------------------------------------------------------------------- /src/RequestMethod/LolStaticData/Versions.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . EndPoint::LOL_STATIC_DATA_DDRAGON_HOST . "/api" . $this->path; 23 | 24 | return $this->getPsr7Request('GET', $uri); 25 | } 26 | 27 | public function mapping(Response $response) { 28 | $json = \GuzzleHttp\json_decode($response->getBody()); 29 | 30 | $mapper = new JsonMapper(); 31 | $mapper->bEnforceMapType = false; 32 | return $mapper->map($json, new VersionListDto()); 33 | } 34 | } -------------------------------------------------------------------------------- /src/RequestMethod/Masteries/MasteriesBySummoner.php: -------------------------------------------------------------------------------- 1 | summonerId = $summonerId; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{summonerId}", $this->summonerId, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | return $mapper->map($json, new MasteryPagesDto()); 44 | } 45 | } -------------------------------------------------------------------------------- /src/RequestMethod/Match/MatchById.php: -------------------------------------------------------------------------------- 1 | id = $id; 29 | } 30 | 31 | public function getRequest() { 32 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 33 | $uri = str_replace("{matchId}", $this->id, $uri); 34 | 35 | return $this->getPsr7Request('GET', $uri); 36 | } 37 | 38 | public function mapping(Response $response) { 39 | $json = \GuzzleHttp\json_decode($response->getBody()); 40 | 41 | $mapper = new JsonMapper(); 42 | 43 | /** @var MatchDto $object */ 44 | $object = $mapper->map($json, new MatchDto()); 45 | return $object; 46 | } 47 | } -------------------------------------------------------------------------------- /src/RequestMethod/Match/MatchesByAccount.php: -------------------------------------------------------------------------------- 1 | encryptedAccountId = $encryptedAccountId; 44 | } 45 | 46 | public function getRequest() { 47 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 48 | $uri = str_replace("{encryptedAccountId}", $this->encryptedAccountId, $uri); 49 | 50 | $query = http_build_query([ 51 | 'beginTime' => ($this->beginTime ? $this->beginTime->getTimestamp() * 1000 : null), 52 | 'endTime' => ($this->endTime ? $this->endTime->getTimestamp() * 1000 : null), 53 | 'beginIndex' => $this->beginIndex, 54 | 'endIndex' => $this->endIndex, 55 | 'queue' => $this->queue, 56 | 'season' => $this->season, 57 | 'champion' => $this->champion, 58 | ]); 59 | 60 | if (strlen($query) > 0) { 61 | $uri .= "?{$query}"; 62 | } 63 | 64 | return $this->getPsr7Request('GET', $uri); 65 | } 66 | 67 | 68 | public function mapping(Response $response) { 69 | $json = \GuzzleHttp\json_decode($response->getBody()); 70 | 71 | $mapper = new JsonMapper(); 72 | 73 | /** @var MatchlistDto $object */ 74 | $object = $mapper->map($json, new MatchlistDto()); 75 | return $object; 76 | } 77 | } -------------------------------------------------------------------------------- /src/RequestMethod/Match/TimelineById.php: -------------------------------------------------------------------------------- 1 | id = $id; 31 | } 32 | 33 | public function getRequest() { 34 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 35 | $uri = str_replace("{matchId}", $this->id, $uri); 36 | 37 | return $this->getPsr7Request('GET', $uri); 38 | } 39 | 40 | public function mapping(Response $response) { 41 | $sizeLimit = 1024 * 500; 42 | 43 | $responseBody = $response->getBody(); 44 | $responseSize = strlen($responseBody); 45 | if ($responseSize > $sizeLimit) { 46 | $responseBody = null; 47 | throw new UnknownException("Timeline response data is too big. size = " . $responseSize); 48 | } 49 | $json = \GuzzleHttp\json_decode($responseBody); 50 | 51 | $mapper = new JsonMapper(); 52 | 53 | /** @var MatchTimelineDto $object */ 54 | $object = $mapper->map($json, new MatchTimelineDto()); 55 | return $object; 56 | } 57 | } -------------------------------------------------------------------------------- /src/RequestMethod/MatchV5/MatchById.php: -------------------------------------------------------------------------------- 1 | 1) { 22 | $this->matchId = $matchId; 23 | } else { 24 | $this->matchId = $platform->platform . '_' . $matchId; 25 | } 26 | } 27 | 28 | public function getRequest() { 29 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 30 | $uri = str_replace("{matchId}", $this->matchId, $uri); 31 | 32 | return $this->getPsr7Request('GET', $uri); 33 | } 34 | 35 | public function mapping(Response $response) { 36 | $json = \GuzzleHttp\json_decode($response->getBody()); 37 | 38 | $mapper = new JsonMapper(); 39 | 40 | /** @var MatchDto $object */ 41 | $object = $mapper->map($json, new MatchDto()); 42 | return $object; 43 | } 44 | } -------------------------------------------------------------------------------- /src/RequestMethod/MatchV5/MatchesByPuuid.php: -------------------------------------------------------------------------------- 1 | puuid = $puuid; 27 | } 28 | 29 | public function getRequest() { 30 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 31 | $uri = str_replace("{puuid}", $this->puuid, $uri); 32 | 33 | $query = http_build_query([ 34 | 'startTime' => ($this->startTime ? $this->startTime->getTimestamp() : null), 35 | 'endTime' => ($this->endTime ? $this->endTime->getTimestamp() : null), 36 | 'queue' => $this->queue, 37 | 'start' => $this->start, 38 | 'count' => $this->count, 39 | 'type' => $this->type, 40 | ]); 41 | 42 | if (strlen($query) > 0) { 43 | $uri .= "?{$query}"; 44 | } 45 | 46 | return $this->getPsr7Request('GET', $uri); 47 | } 48 | 49 | public function mapping(Response $response) { 50 | /** List[String] */ 51 | return \GuzzleHttp\json_decode($response->getBody()); 52 | } 53 | } -------------------------------------------------------------------------------- /src/RequestMethod/MatchV5/TimelineById.php: -------------------------------------------------------------------------------- 1 | 1) { 24 | $this->matchId = $matchId; 25 | } else { 26 | $this->matchId = $platform->platform . '_' . $matchId; 27 | } 28 | } 29 | 30 | public function getRequest() { 31 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 32 | $uri = str_replace("{matchId}", $this->matchId, $uri); 33 | 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $sizeLimit = 1024 * 10000; 39 | 40 | $responseBody = $response->getBody(); 41 | $responseSize = strlen($responseBody); 42 | if ($responseSize > $sizeLimit) { 43 | $responseBody = null; 44 | throw new UnknownException("Timeline response data is too big. size = " . $responseSize); 45 | } 46 | $json = \GuzzleHttp\json_decode($responseBody); 47 | 48 | $mapper = new JsonMapper(); 49 | 50 | /** @var TimelineDto $object */ 51 | $object = $mapper->map($json, new TimelineDto()); 52 | return $object; 53 | } 54 | } -------------------------------------------------------------------------------- /src/RequestMethod/RequestMethodAbstract.php: -------------------------------------------------------------------------------- 1 | setPlatform($platform); 35 | } 36 | 37 | protected function setPlatform(Platform $platform) { 38 | $this->platform = $platform; 39 | } 40 | 41 | /** 42 | * @return Platform 43 | */ 44 | public function getPlatform() { 45 | return $this->platform; 46 | } 47 | 48 | /** 49 | * @param $method 50 | * @param $uri 51 | * @param array $headers 52 | * @param null $body 53 | * 54 | * @return Request 55 | * @throws RequiredParameterNotFilledException 56 | */ 57 | protected function getPsr7Request($method, $uri, $headers = [], $body = null) { 58 | // { 나 } 가 남아있으면 파라미터가 치환 안된 상태임. 수정 필요. 59 | if (strpos($uri, '{') !== false || strpos($uri, '}') !== false) { 60 | throw new RequiredParameterNotFilledException("URI 에 아직 파라미터가 채워지지 않은 것이 있습니다. (You tried: {$uri})"); 61 | } 62 | 63 | return new Request($method, $uri, $headers, $body); 64 | } 65 | 66 | /** 67 | * @return Request 68 | */ 69 | abstract public function getRequest(); 70 | 71 | /** 72 | * @param $params 73 | * 74 | * @return string 75 | */ 76 | protected static function buildParams(array $params = null) { 77 | $parameter = []; 78 | 79 | foreach ($params as $key => $val) { 80 | if ($val === null) { 81 | // null 이면 패스 82 | } elseif (is_array($val) || is_object($val)) { 83 | // 표준: key[]=abc&key[]=fff&key[]=rrr 84 | // RiotAPI: key=abc&key=fff&key=rrr 85 | foreach ($val as $_val) { 86 | $parameter[] = urlencode($key) . "=" . urlencode((string) $_val); 87 | } 88 | } elseif ($val === true) { 89 | $parameter[] = urlencode($key) . "=true"; 90 | } elseif ($val === false) { 91 | $parameter[] = urlencode($key) . "=false"; 92 | } else { 93 | $parameter[] = urlencode($key) . "=" . urlencode((string) $val); 94 | } 95 | } 96 | 97 | return implode('&', $parameter); 98 | } 99 | 100 | /** 101 | * @param Response $response 102 | * 103 | * @return mixed|BaseDto|BaseArrayDto|array 104 | */ 105 | abstract public function mapping(Response $response); 106 | } -------------------------------------------------------------------------------- /src/RequestMethod/Runes/RunesBySummoner.php: -------------------------------------------------------------------------------- 1 | summonerId = $summonerId; 28 | } 29 | 30 | public function getRequest() { 31 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 32 | $uri = str_replace("{summonerId}", $this->summonerId, $uri); 33 | 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $json = \GuzzleHttp\json_decode($response->getBody()); 39 | 40 | $mapper = new JsonMapper(); 41 | 42 | return $mapper->map($json, new RunePagesDto()); 43 | } 44 | } -------------------------------------------------------------------------------- /src/RequestMethod/Spectator/ActiveGameBySummoner.php: -------------------------------------------------------------------------------- 1 | puuid = $puuid; 32 | } 33 | 34 | public function getRequest() { 35 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 36 | $uri = str_replace("{encryptedPUUID}", $this->puuid, $uri); 37 | 38 | return $this->getPsr7Request('GET', $uri); 39 | } 40 | 41 | public function mapping(Response $response) { 42 | $json = \GuzzleHttp\json_decode($response->getBody()); 43 | 44 | $mapper = new JsonMapper(); 45 | 46 | /** @var CurrentGameInfo $object */ 47 | $object = $mapper->map($json, new CurrentGameInfo()); 48 | return $object; 49 | } 50 | } -------------------------------------------------------------------------------- /src/RequestMethod/Spectator/FeaturedGames.php: -------------------------------------------------------------------------------- 1 | platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 23 | 24 | return $this->getPsr7Request('GET', $uri); 25 | } 26 | 27 | public function mapping(Response $response) { 28 | $json = \GuzzleHttp\json_decode($response->getBody()); 29 | 30 | $mapper = new JsonMapper(); 31 | 32 | /** @var \RiotQuest\Dto\Spectator\FeaturedGames $object */ 33 | $object = $mapper->map($json, new \RiotQuest\Dto\Spectator\FeaturedGames()); 34 | return $object; 35 | } 36 | } -------------------------------------------------------------------------------- /src/RequestMethod/Summoner/SummonerByAccountId.php: -------------------------------------------------------------------------------- 1 | encryptedAccountId = $encryptedAccountId; 32 | } 33 | 34 | public function getRequest() { 35 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 36 | $uri = str_replace("{encryptedAccountId}", $this->encryptedAccountId, $uri); 37 | 38 | return $this->getPsr7Request('GET', $uri); 39 | } 40 | 41 | public function mapping(Response $response) { 42 | $json = \GuzzleHttp\json_decode($response->getBody()); 43 | 44 | $mapper = new JsonMapper(); 45 | 46 | /** @var SummonerDto $object */ 47 | $object = $mapper->map($json, new SummonerDto()); 48 | return $object; 49 | } 50 | } -------------------------------------------------------------------------------- /src/RequestMethod/Summoner/SummonerById.php: -------------------------------------------------------------------------------- 1 | encryptedSummonerId = $encryptedSummonerId; 36 | } 37 | 38 | public function getRequest() { 39 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 40 | $uri = str_replace("{encryptedSummonerId}", $this->encryptedSummonerId, $uri); 41 | 42 | return $this->getPsr7Request('GET', $uri); 43 | } 44 | 45 | public function mapping(Response $response) { 46 | $json = \GuzzleHttp\json_decode($response->getBody()); 47 | 48 | $mapper = new JsonMapper(); 49 | 50 | /** @var SummonerDto $object */ 51 | $object = $mapper->map($json, new SummonerDto()); 52 | return $object; 53 | } 54 | } -------------------------------------------------------------------------------- /src/RequestMethod/Summoner/SummonerByName.php: -------------------------------------------------------------------------------- 1 | name = $name; 28 | } 29 | 30 | public function getRequest() { 31 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 32 | $uri = str_replace("{summonerName}", $this->name, $uri); 33 | 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $json = \GuzzleHttp\json_decode($response->getBody()); 39 | 40 | $mapper = new JsonMapper(); 41 | 42 | /** @var SummonerDto $object */ 43 | $object = $mapper->map($json, new SummonerDto()); 44 | return $object; 45 | } 46 | } -------------------------------------------------------------------------------- /src/RequestMethod/Summoner/SummonerByPUUID.php: -------------------------------------------------------------------------------- 1 | encryptedPUUID = $encryptedPUUID; 28 | } 29 | 30 | public function getRequest() { 31 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 32 | $uri = str_replace("{encryptedPUUID}", $this->encryptedPUUID, $uri); 33 | 34 | return $this->getPsr7Request('GET', $uri); 35 | } 36 | 37 | public function mapping(Response $response) { 38 | $json = \GuzzleHttp\json_decode($response->getBody()); 39 | 40 | $mapper = new JsonMapper(); 41 | 42 | /** @var SummonerDto $object */ 43 | $object = $mapper->map($json, new SummonerDto()); 44 | return $object; 45 | } 46 | } -------------------------------------------------------------------------------- /src/RequestMethod/SummonerV3/SummonerById.php: -------------------------------------------------------------------------------- 1 | summonerId = $summonerId; 36 | } 37 | 38 | public function getRequest() { 39 | $uri = $this->platform->apiScheme . "://" . $this->platform->apiHost . "" . $this->path; 40 | $uri = str_replace("{summonerId}", $this->summonerId, $uri); 41 | 42 | return $this->getPsr7Request('GET', $uri); 43 | } 44 | 45 | public function mapping(Response $response) { 46 | $json = \GuzzleHttp\json_decode($response->getBody()); 47 | 48 | $mapper = new JsonMapper(); 49 | 50 | /** @var SummonerDto $object */ 51 | $object = $mapper->map($json, new SummonerDto()); 52 | return $object; 53 | } 54 | } -------------------------------------------------------------------------------- /src/Util/Util.php: -------------------------------------------------------------------------------- 1 | call($riotApi); 4 | // $summonerDto is instanceof Dto\Summoner\SummonerDto); 5 | // $summonerDto->revisionDate is instanceof Dto\DateTime); 6 | // 실패시 RequestFailedException 7 | ``` 8 | 9 | ```php 10 | $riotApiAsync = new RiotQuest\RiotAPIAsync("your_riotapi_key"); 11 | $riotApiAsync 12 | ->add(new RequestMethod\Summoner\SummonersByName(Platform::KR(), "kargnas"), 13 | function (\RiotQuest\Dto\Summoner\SummonerDto $summonerDto) { 14 | // $summonerDto is instanceof Dto\Summoner\SummonerDto); 15 | // $summonerDto->revisionDate is instanceof Dto\DateTime); 16 | }) 17 | ->add(new RequestMethod\Summoner\SummonersByName(Platform::KR(), "hideonbush"), 18 | function (\RiotQuest\Dto\Summoner\SummonerDto $summonerDto) { 19 | // $summonerDto is instanceof Dto\Summoner\SummonerDto); 20 | // $summonerDto->revisionDate is instanceof Dto\DateTime); 21 | }, function(\GuzzleHttp\Exception\RequestException $response){ 22 | // 이 함수 두번째 파라미터)는 Optional. 실패시 Callback 이 지정되어 있지 않으면 RequestFailedException 을 발생한다. 23 | }) 24 | ->exec(); 25 | ``` -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 |