DigitalOcean   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 48
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthorizeUri() 0 3 1
A getName() 0 3 1
A getRequestTokenUri() 0 3 1
A getBaseUri() 0 3 1
A getIdentity() 0 9 1
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 DigitalOcean extends \SocialConnect\OAuth2\AbstractProvider
15
{
16
    const NAME = 'digital-ocean';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 4
    public function getBaseUri()
22
    {
23 4
        return 'https://api.digitalocean.com/v2/';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function getAuthorizeUri()
30
    {
31 2
        return 'https://cloud.digitalocean.com/v1/oauth/authorize';
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function getRequestTokenUri()
38
    {
39 2
        return 'https://cloud.digitalocean.com/v1/oauth/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', 'account', [], $accessToken);
56
57 1
        $hydrator = new ArrayHydrator([
58
            'uuid' => 'id',
59
        ]);
60
61 1
        return $hydrator->hydrate(new User(), $response['account']);
62
    }
63
}
64