1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the wohali/oauth2-discord-new library |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright Copyright (c) Joan Touzet <[email protected]> |
9
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
10
|
|
|
* @link https://packagist.org/packages/wohali/oauth2-discord-new Packagist |
11
|
|
|
* @link https://github.com/wohali/oauth2-discord-new GitHub |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Wohali\OAuth2\Client\Provider; |
15
|
|
|
|
16
|
|
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
17
|
|
|
|
18
|
|
|
class DiscordResourceOwner implements ResourceOwnerInterface |
19
|
|
|
{ |
20
|
|
|
use ArrayAccessorTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Raw response |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
protected $response; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Creates new resource owner. |
31
|
|
|
* |
32
|
|
|
* @param array $response |
33
|
|
|
*/ |
34
|
3 |
|
public function __construct(array $response = array()) |
35
|
|
|
{ |
36
|
3 |
|
$this->response = $response; |
37
|
3 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Get resource owner ID |
41
|
|
|
* |
42
|
|
|
* @return string|null |
43
|
|
|
*/ |
44
|
3 |
|
public function getId() |
45
|
|
|
{ |
46
|
3 |
|
return $this->getValueByKey($this->response, 'id'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Get resource owner username |
51
|
|
|
* |
52
|
|
|
* @return string|null |
53
|
|
|
*/ |
54
|
3 |
|
public function getUsername() |
55
|
|
|
{ |
56
|
3 |
|
return $this->getValueByKey($this->response, 'username'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get resource owner discriminator |
61
|
|
|
* |
62
|
|
|
* @return string|null |
63
|
|
|
*/ |
64
|
3 |
|
public function getDiscriminator() |
65
|
|
|
{ |
66
|
3 |
|
return $this->getValueByKey($this->response, 'discriminator'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Get resource owner avatar hash |
71
|
|
|
* |
72
|
|
|
* @return string|null |
73
|
|
|
*/ |
74
|
3 |
|
public function getAvatarHash() |
75
|
|
|
{ |
76
|
3 |
|
return $this->getValueByKey($this->response, 'avatar'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Get resource owner verified flag |
81
|
|
|
* |
82
|
|
|
* @return bool |
83
|
|
|
*/ |
84
|
3 |
|
public function getVerified() |
85
|
|
|
{ |
86
|
3 |
|
return $this->getValueByKey($this->response, 'verified', false); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get resource owner email |
91
|
|
|
* |
92
|
|
|
* @return string|null |
93
|
|
|
*/ |
94
|
3 |
|
public function getEmail() |
95
|
|
|
{ |
96
|
3 |
|
return $this->getValueByKey($this->response, 'email'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Returns the raw resource owner response. |
101
|
|
|
* |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
3 |
|
public function toArray() |
105
|
|
|
{ |
106
|
3 |
|
return $this->response; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|