Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
StravaFetcher | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
fetchTokenDataForCode | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Olz\Fetchers; |
4 | |
5 | class StravaFetcher { |
6 | /** |
7 | * @param array<string, mixed> $token_request_data |
8 | * |
9 | * @return ?array<string, mixed> |
10 | */ |
11 | public function fetchTokenDataForCode(array $token_request_data): ?array { |
12 | $strava_token_url = 'https://www.strava.com/api/v3/oauth/token'; |
13 | |
14 | $ch = curl_init(); |
15 | curl_setopt($ch, CURLOPT_URL, $strava_token_url); |
16 | curl_setopt($ch, CURLOPT_POST, true); |
17 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($token_request_data, '', '&')); |
18 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
19 | $token_result = curl_exec($ch); |
20 | $token_response = json_decode(!is_bool($token_result) ? $token_result : '', true); |
21 | curl_close($ch); |
22 | |
23 | return $token_response; |
24 | } |
25 | } |