Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
45 | 2 | public function getToken() |
|
46 | { |
||
47 | $data = [ |
||
48 | 2 | self::GRANT_TYPE => self::GRANT_TYPE_CLIENT_CREDENTIALS |
|
49 | ]; |
||
50 | 2 | if (!empty($this->credentials->getScope())) { |
|
51 | 2 | $data[self::SCOPE] = $this->credentials->getScope(); |
|
52 | } |
||
53 | $options = [ |
||
54 | 2 | 'form_params' => $data, |
|
55 | 2 | 'auth' => [$this->credentials->getClientId(), $this->credentials->getClientSecret()] |
|
56 | ]; |
||
57 | |||
58 | 2 | $result = $this->client->post($this->accessTokenUrl, $options); |
|
59 | |||
60 | 2 | $body = json_decode((string)$result->getBody(), true); |
|
61 | 2 | return new Token((string)$body[self::ACCESS_TOKEN], (int)$body[self::EXPIRES_IN], $body[self::SCOPE]); |
|
62 | } |
||
64 |