DocusignUser   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 94.74%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 14
c 4
b 0
f 0
dl 0
loc 61
ccs 18
cts 19
cp 0.9474
rs 10
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getToken() 0 3 1
A toArray() 0 3 1
A __construct() 0 6 1
A getName() 0 3 1
A getEmail() 0 3 1
A getId() 0 3 1
A getDefaultAccount() 0 9 3
1
<?php
2
3
namespace Sarhan\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
use League\OAuth2\Client\Token\AccessToken;
7
8
class DocusignUser implements ResourceOwnerInterface
9
{
10
    private $userInfo;
11
    private $token;
12
13 7
    public function __construct(
14
        array $userInfo,
15
        AccessToken $token
16
    ) {
17 7
        $this->userInfo = $userInfo;
18 7
        $this->token = $token;
19 7
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24 1
    public function getId()
25
    {
26 1
        return $this->userInfo['sub'];
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32 2
    public function toArray()
33
    {
34 2
        return $this->userInfo;
35
    }
36
37 1
    public function getName()
38
    {
39 1
        return $this->userInfo['name'];
40
    }
41
42 1
    public function getEmail()
43
    {
44 1
        return $this->userInfo['email'];
45
    }
46
47
    /**
48
     * Get default user account, if any exists.
49
     *
50
     * @return array|null
51
     */
52 1
    public function getDefaultAccount()
53
    {
54 1
        foreach ($this->userInfo['accounts'] as $account) {
55 1
            if ($account['is_default']) {
56 1
                return $account;
57
            }
58
        }
59
60
        return null;
61
    }
62
63
    /**
64
     * @return AccessToken
65
     */
66 1
    public function getToken()
67
    {
68 1
        return $this->token;
69
    }
70
}
71