Total Complexity | 9 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 94.74% |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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() |
|
69 | } |
||
70 | } |
||
71 |