Conditions | 2 |
Paths | 2 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Arcanedev\Socialite\OAuth\One; |
||
21 | public function user() |
||
22 | { |
||
23 | if ( ! $this->hasNecessaryVerifier()) { |
||
24 | throw new InvalidArgumentException( |
||
25 | 'Invalid request. Missing OAuth verifier.' |
||
26 | ); |
||
27 | } |
||
28 | |||
29 | $user = $this->server->getUserDetails($token = $this->getToken()); |
||
30 | $extraDetails = [ |
||
31 | 'location' => $user->location, |
||
32 | 'description' => $user->description, |
||
33 | ]; |
||
34 | |||
35 | $instance = (new User)->setRaw(array_merge($user->extra, $user->urls, $extraDetails)) |
||
36 | ->setToken($token->getIdentifier(), $token->getSecret()); |
||
37 | |||
38 | return $instance->map([ |
||
39 | 'id' => $user->uid, |
||
40 | 'nickname' => $user->nickname, |
||
41 | 'name' => $user->name, |
||
42 | 'email' => $user->email, |
||
43 | 'avatar' => $user->imageUrl, |
||
44 | 'avatar_original' => str_replace('_normal', '', $user->imageUrl), |
||
45 | ]); |
||
46 | } |
||
47 | } |
||
48 |