TwitterProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 36
ccs 0
cts 23
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B user() 0 26 2
1
<?php namespace Arcanedev\Socialite\OAuth\One;
2
3
use InvalidArgumentException;
4
5
/**
6
 * Class     TwitterProvider
7
 *
8
 * @package  Arcanedev\Socialite\OAuth\One
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class TwitterProvider extends AbstractProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Main Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function user()
21
    {
22
        if ( ! $this->hasNecessaryVerifier()) {
23
            throw new InvalidArgumentException(
24
                'Invalid request. Missing OAuth verifier.'
25
            );
26
        }
27
28
        $user         = $this->server->getUserDetails($token = $this->getToken());
29
        $extraDetails = [
30
            'location'    => $user->location,
31
            'description' => $user->description,
32
        ];
33
34
        $instance = (new User)->setRaw(array_merge($user->extra, $user->urls, $extraDetails))
35
            ->setToken($token->getIdentifier(), $token->getSecret());
36
37
        return $instance->map([
38
            'id'              => $user->uid,
39
            'nickname'        => $user->nickname,
40
            'name'            => $user->name,
41
            'email'           => $user->email,
42
            'avatar'          => $user->imageUrl,
43
            'avatar_original' => str_replace('_normal', '', $user->imageUrl),
44
        ]);
45
    }
46
}
47