1 | <?php |
||
20 | class BattlenetHttpClient |
||
21 | { |
||
22 | /** |
||
23 | * @var Repository |
||
24 | */ |
||
25 | protected $cache; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $cacheKey = 'xklusive.battlenetapi.cache'; |
||
31 | |||
32 | /** |
||
33 | * Http client. |
||
34 | * |
||
35 | * @var object GuzzleHttp\Client |
||
36 | */ |
||
37 | protected $client; |
||
38 | |||
39 | /** |
||
40 | * Game name for url prefix. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $gameParam; |
||
45 | |||
46 | /** |
||
47 | * Battle.net Connection Options. |
||
48 | * |
||
49 | * @var Collection |
||
50 | */ |
||
51 | protected $options; |
||
52 | |||
53 | /** |
||
54 | * BattlnetHttpClient constructor. |
||
55 | * |
||
56 | * @param $repository Illuminate\Contracts\Cache\Repository |
||
57 | */ |
||
58 | public function __construct(Repository $repository) |
||
65 | |||
66 | /** |
||
67 | * Creates a Mock Response based on the given array. |
||
68 | * Used to imitate API response from Blizzard, without calling the actual API. |
||
69 | * |
||
70 | * @param $responses array |
||
71 | */ |
||
72 | public function createMockResponse(array $responses = null) |
||
93 | |||
94 | /** |
||
95 | * Create a new client with the given handler. |
||
96 | * Right now only used for testing. |
||
97 | * |
||
98 | * @param $handler GuzzleHttp\HandlerStack |
||
99 | */ |
||
100 | protected function setGuzzHandler(HandlerStack $handler = null) |
||
109 | |||
110 | /** |
||
111 | * Make request with API url and specific URL suffix. |
||
112 | * |
||
113 | * @return Collection|ClientException |
||
114 | */ |
||
115 | protected function api() |
||
183 | |||
184 | /** |
||
185 | * Cache the api response data if cache set to true in config file. |
||
186 | * |
||
187 | * @param array $options Options |
||
188 | * @param string $method method name |
||
189 | * @param string $apiEndPoint |
||
190 | * @return Collection|ClientException |
||
191 | */ |
||
192 | public function cache($apiEndPoint, array $options, $method) |
||
215 | |||
216 | /** |
||
217 | * Get default query options from configuration file. |
||
218 | * |
||
219 | * @return Collection |
||
220 | */ |
||
221 | private function getDefaultOptions() |
||
228 | |||
229 | /** |
||
230 | * Set default option if a 'query' key is provided |
||
231 | * else create 'query' key with default options. |
||
232 | * |
||
233 | * @param Collection $options |
||
234 | * |
||
235 | * @return Collection api response |
||
236 | */ |
||
237 | private function getQueryOptions(Collection $options) |
||
252 | |||
253 | /** |
||
254 | * Get API domain provided in configuration. |
||
255 | * |
||
256 | * @return string |
||
257 | */ |
||
258 | private function getApiEndPoint() |
||
262 | |||
263 | /** |
||
264 | * Get API key provided in configuration. |
||
265 | * |
||
266 | * @return string |
||
267 | */ |
||
268 | private function getApiKey() |
||
272 | |||
273 | /** |
||
274 | * Get API locale provided in configuration. |
||
275 | * |
||
276 | * @return string |
||
277 | */ |
||
278 | private function getLocale() |
||
282 | |||
283 | /** |
||
284 | * This method wraps the given value in a collection when applicable. |
||
285 | * |
||
286 | * @return Collection |
||
287 | */ |
||
288 | public function wrapCollection($collection) |
||
296 | |||
297 | /** |
||
298 | * Build the cache configuration. |
||
299 | * |
||
300 | * @param string $method |
||
301 | */ |
||
302 | private function buildCahceOptions($method) |
||
317 | } |
||
318 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.