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