Conditions | 2 |
Paths | 2 |
Total Lines | 29 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
39 | public function getIdentity(AccessTokenInterface $accessToken) |
||
40 | { |
||
41 | $response = $this->httpClient->request( |
||
42 | $this->getBaseUri() . 'user', |
||
43 | [ |
||
44 | 'access_token' => $accessToken->getToken() |
||
45 | ] |
||
46 | ); |
||
47 | |||
48 | if (!$response->isSuccess()) { |
||
49 | throw new InvalidResponse( |
||
50 | 'API response with error code', |
||
51 | $response |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | $body = $response->getBody(); |
||
56 | $result = json_decode($body); |
||
57 | |||
58 | $hydrator = new ObjectMap( |
||
59 | [ |
||
60 | 'id' => 'id', |
||
61 | 'login' => 'username', |
||
62 | 'email' => 'email', |
||
63 | ] |
||
64 | ); |
||
65 | |||
66 | return $hydrator->hydrate(new User(), $result); |
||
67 | } |
||
68 | } |
||
69 |