1 | <?php |
||
29 | class ApiClient |
||
30 | { |
||
31 | const REGION_BR = 'br'; |
||
32 | const REGION_EUNE = 'eune'; |
||
33 | const REGION_EUW = 'euw'; |
||
34 | const REGION_KR = 'kr'; |
||
35 | const REGION_LAN = 'lan'; |
||
36 | const REGION_LAS = 'las'; |
||
37 | const REGION_NA = 'na'; |
||
38 | const REGION_OCE = 'oce'; |
||
39 | const REGION_RU = 'ru'; |
||
40 | const REGION_TR = 'tr'; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | public static $availableRegions = [ |
||
46 | self::REGION_BR, |
||
47 | self::REGION_EUNE, |
||
48 | self::REGION_EUW, |
||
49 | self::REGION_KR, |
||
50 | self::REGION_LAN, |
||
51 | self::REGION_LAS, |
||
52 | self::REGION_NA, |
||
53 | self::REGION_OCE, |
||
54 | self::REGION_RU, |
||
55 | self::REGION_TR |
||
56 | ]; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $region; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $apiKey; |
||
67 | |||
68 | /** |
||
69 | * @var Client |
||
70 | */ |
||
71 | protected $httpClient; |
||
72 | |||
73 | /** |
||
74 | * @var CacheProvider |
||
75 | */ |
||
76 | protected $cacheProvider; |
||
77 | |||
78 | /** |
||
79 | * @param string $region |
||
80 | * @param string $apiKey |
||
81 | * @param CacheProvider $cacheProvider |
||
82 | * @param Client $client |
||
83 | * |
||
84 | * @throws InvalidRegionException |
||
85 | */ |
||
86 | 3 | public function __construct($region, $apiKey, CacheProvider $cacheProvider = null, Client $client = null) |
|
97 | |||
98 | /** |
||
99 | * @param CacheProvider $cacheProvider |
||
100 | */ |
||
101 | 1 | public function setCacheProvider(CacheProvider $cacheProvider) |
|
105 | |||
106 | /** |
||
107 | * @return CacheProvider |
||
108 | */ |
||
109 | 1 | public function getCacheProvider() |
|
113 | |||
114 | /** |
||
115 | * @return Client |
||
116 | */ |
||
117 | 1 | public function getHttpClient() |
|
121 | |||
122 | /** |
||
123 | * @return string |
||
124 | */ |
||
125 | 1 | public function getRegion() |
|
129 | |||
130 | /** |
||
131 | * @return string |
||
132 | */ |
||
133 | 1 | public function getApiKey() |
|
137 | |||
138 | /** |
||
139 | * @return MatchListApi |
||
140 | */ |
||
141 | 1 | public function getMatchListApi() |
|
145 | |||
146 | /** |
||
147 | * @return MatchApi |
||
148 | */ |
||
149 | 1 | public function getMatchApi() |
|
153 | |||
154 | /** |
||
155 | * @return SummonerApi |
||
156 | */ |
||
157 | 1 | public function getSummonerApi() |
|
161 | |||
162 | /** |
||
163 | * @return ChampionApi |
||
164 | */ |
||
165 | 1 | public function getChampionApi() |
|
169 | |||
170 | /** |
||
171 | * @return FeaturedGamesApi |
||
172 | */ |
||
173 | 1 | public function getFeaturedGamesApi() |
|
177 | |||
178 | /** |
||
179 | * @return StatsApi |
||
180 | */ |
||
181 | 1 | public function getStatsApi() |
|
185 | |||
186 | /** |
||
187 | * @return TeamApi |
||
188 | */ |
||
189 | 1 | public function getTeamApi() |
|
193 | |||
194 | /** |
||
195 | * @return GameApi |
||
196 | */ |
||
197 | 1 | public function getGameApi() |
|
201 | |||
202 | /** |
||
203 | * @return CurrentGameApi |
||
204 | */ |
||
205 | 1 | public function getCurrentGameApi() |
|
209 | |||
210 | /** |
||
211 | * @return LeagueApi |
||
212 | */ |
||
213 | 1 | public function getLeagueApi() |
|
217 | |||
218 | /** |
||
219 | * @return StaticDataApi |
||
220 | */ |
||
221 | 1 | public function getStaticDataApi() |
|
225 | |||
226 | /** |
||
227 | * @return StatusApi |
||
228 | */ |
||
229 | 1 | public function getStatusApi() |
|
233 | |||
234 | /** |
||
235 | * @return ChampionMasteryApi |
||
236 | */ |
||
237 | public function getChampionMasteryApi() |
||
241 | |||
242 | /** |
||
243 | * @return string |
||
244 | */ |
||
245 | 1 | public function getBaseUrlWithRegion() |
|
249 | |||
250 | /** |
||
251 | * @return string |
||
252 | */ |
||
253 | 1 | public function getGlobalUrl() |
|
257 | |||
258 | /** |
||
259 | * @return string |
||
260 | */ |
||
261 | 1 | public function getStatusUrl() |
|
265 | |||
266 | /** |
||
267 | * @param ApiResult $apiResult |
||
268 | * @param int $ttl |
||
269 | */ |
||
270 | 1 | public function cacheApiResult(ApiResult $apiResult, $ttl = 60) |
|
274 | } |
||
275 |