Amazon::getIdentity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
declare(strict_types=1);
7
8
namespace SocialConnect\OAuth2\Provider;
9
10
use SocialConnect\Common\ArrayHydrator;
11
use SocialConnect\Provider\AccessTokenInterface;
12
use SocialConnect\Common\Entity\User;
13
14
class Amazon extends \SocialConnect\OAuth2\AbstractProvider
15
{
16
    const NAME = 'amazon';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 4
    public function getBaseUri()
22
    {
23 4
        return 'https://api.amazon.com/';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function getAuthorizeUri()
30
    {
31 2
        return 'https://www.amazon.com/ap/oa';
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function getRequestTokenUri()
38
    {
39 2
        return 'https://api.amazon.com/auth/o2/token';
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function getName()
46
    {
47 3
        return self::NAME;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 3
    public function getIdentity(AccessTokenInterface $accessToken)
54
    {
55 3
        $response = $this->request('GET', 'user/profile', [], $accessToken);
56
57 1
        $hydrator = new ArrayHydrator([
58
            'user_id' => 'id',
59
            'name' => 'firstname',
60
        ]);
61
62 1
        return $hydrator->hydrate(new User(), $response);
63
    }
64
}
65