Passed
Push — master ( 132ee1...9612a9 )
by Alaa
01:36
created

DocusignUser::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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() : string
25
    {
26 1
    	return $this->userInfo['sub'];
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32 2
    public function toArray() : array
33
    {
34 2
    	return $this->userInfo;
35
    }
36
37 1
    public function getName() : string
38
    {
39 1
    	return $this->userInfo['name'];
40
    }
41
42 1
    public function getEmail() : string
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() : ?array
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 1
    public function getToken() : AccessToken
64
    {
65 1
    	return $this->token;
66
    }
67
}