1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CrudSys\OAuth2\Client\Entity; |
4
|
|
|
|
5
|
|
|
use League\OAuth2\Client\Provider\ResourceOwnerInterface; |
6
|
|
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
7
|
|
|
|
8
|
|
|
class User implements ResourceOwnerInterface |
9
|
|
|
{ |
10
|
|
|
use ArrayAccessorTrait; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Raw response |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
protected array $response; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param array $response |
20
|
|
|
*/ |
21
|
|
|
public function __construct(array $response) |
22
|
|
|
{ |
23
|
|
|
$this->response = $response; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function toArray(): array |
27
|
|
|
{ |
28
|
|
|
return $this->response; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getId(): string |
32
|
|
|
{ |
33
|
|
|
return $this->getValueByKey($this->response, 'id'); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getUsername(): string |
37
|
|
|
{ |
38
|
|
|
return $this->getValueByKey($this->response, 'username'); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function isPatron(): bool |
42
|
|
|
{ |
43
|
|
|
return $this->getValueByKey($this->response, 'patron'); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function isOnline(): bool |
47
|
|
|
{ |
48
|
|
|
return $this->getValueByKey($this->response, 'online'); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getProfile(): array |
52
|
|
|
{ |
53
|
|
|
return $this->getValueByKey($this->response, 'profile'); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getCountry(): string |
57
|
|
|
{ |
58
|
|
|
return $this->getValueByKey($this->response, 'profile.country'); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getLocation(): string |
62
|
|
|
{ |
63
|
|
|
return $this->getValueByKey($this->response, 'profile.location'); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getBio(): string |
67
|
|
|
{ |
68
|
|
|
return $this->getValueByKey($this->response, 'profile.bio'); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getFirstName(): string |
72
|
|
|
{ |
73
|
|
|
return $this->getValueByKey($this->response, 'profile.firstName'); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getLastName(): string |
77
|
|
|
{ |
78
|
|
|
return $this->getValueByKey($this->response, 'profile.lastName'); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getLinks(): string |
82
|
|
|
{ |
83
|
|
|
return $this->getValueByKey($this->response, 'profile.links'); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getUrl(): string |
87
|
|
|
{ |
88
|
|
|
return $this->getValueByKey($this->response, 'url'); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function getCompletionRate() |
92
|
|
|
{ |
93
|
|
|
return $this->getValueByKey($this->response, 'completionRate'); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|