Completed
Push — master ( 50beb4...8d6a23 )
by Michał
02:12
created

LinkedIn::getIdentifyUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php namespace nyx\auth\id\protocols\oauth2\providers;
2
3
// Internal dependencies
4
use nyx\auth\id\protocols\oauth2;
5
use nyx\auth;
6
7
/**
8
 * LinkedIn Identity Provider (OAuth 2.0)
9
 *
10
 * @package     Nyx\Auth
11
 * @version     0.1.0
12
 * @author      Michal Chojnacki <[email protected]>
13
 * @copyright   2012-2017 Nyx Dev Team
14
 * @link        https://github.com/unyx/nyx
15
 */
16
class LinkedIn extends oauth2\Provider
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21
    const SCOPE_SEPARATOR = ' ';
22
23
    /**
24
     * {@inheritDoc}
25
     */
26
    const URL_AUTHORIZE = 'https://www.linkedin.com/oauth/v2/authorization';
27
    const URL_EXCHANGE  = 'https://www.linkedin.com/oauth/v2/accessToken';
28
    const URL_IDENTIFY  = 'https://api.linkedin.com/v1/people';
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    const IDENTITY = auth\id\identities\LinkedIn::class;
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    protected $defaultScopes = ['r_basicprofile', 'r_emailaddress'];
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function getIdentifyUrl() : string
44
    {
45
        $fields = [
46
            'id',                   'first-name',   'last-name',    'formatted-name',
47
            'email-address',        'headline',     'location',     'industry',
48
            'public-profile-url',   'picture-url',
49
        ];
50
51
        // Talk about proprietary 'standards'...
52
        return static::URL_IDENTIFY.'/~:('.implode(',', $fields).')';
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58 View Code Duplication
    protected function getDefaultRequestOptions(auth\interfaces\Token $token = null) : array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        return array_merge_recursive(parent::getDefaultRequestOptions($token), [
61
            'headers' => [
62
                'x-li-format' => 'json'
63
            ]
64
        ]);
65
    }
66
}
67