1
|
|
|
<?php namespace League\OAuth2\Client\Provider; |
2
|
|
|
|
3
|
|
|
use League\OAuth2\Client\Tool\ArrayAccessorTrait; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @property array $response |
7
|
|
|
* @property string $uid |
8
|
|
|
*/ |
9
|
|
|
class LinkedInResourceOwner extends GenericResourceOwner |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
use ArrayAccessorTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Raw response |
16
|
|
|
* |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
protected $response; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Creates new resource owner. |
23
|
|
|
* |
24
|
|
|
* @param array $response |
25
|
|
|
*/ |
26
|
6 |
|
public function __construct(array $response = array()) |
27
|
|
|
{ |
28
|
6 |
|
$this->response = $response; |
29
|
6 |
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Gets resource owner attribute by key. The key supports dot notation. |
33
|
|
|
* |
34
|
|
|
* @return mixed |
35
|
|
|
*/ |
36
|
6 |
|
public function getAttribute($key) |
37
|
|
|
{ |
38
|
6 |
|
return $this->getValueByKey($this->response, (string) $key); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get user email |
43
|
|
|
* |
44
|
|
|
* @return string|null |
45
|
|
|
*/ |
46
|
6 |
|
public function getEmail() |
47
|
|
|
{ |
48
|
6 |
|
return $this->getAttribute('emailAddress'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get user firstname |
53
|
|
|
* |
54
|
|
|
* @return string|null |
55
|
|
|
*/ |
56
|
6 |
|
public function getFirstName() |
57
|
|
|
{ |
58
|
6 |
|
return $this->getAttribute('firstName'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get user imageurl |
63
|
|
|
* |
64
|
|
|
* @return string|null |
65
|
|
|
*/ |
66
|
6 |
|
public function getImageurl() |
67
|
|
|
{ |
68
|
6 |
|
return $this->getAttribute('pictureUrl'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get user original photo url |
73
|
|
|
* |
74
|
|
|
* @return string|null |
75
|
|
|
*/ |
76
|
6 |
|
public function getImageOriginalUrl() |
77
|
|
|
{ |
78
|
6 |
|
$urls = $this->getAttribute('pictureUrls'); |
79
|
|
|
if (!empty($urls['values'])) { |
80
|
|
|
$originalUrl = reset($urls['values']); |
81
|
|
|
return $originalUrl; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return NULL; |
85
|
|
|
} |
86
|
6 |
|
|
87
|
|
|
/** |
88
|
6 |
|
* Get user lastname |
89
|
|
|
* |
90
|
|
|
* @return string|null |
91
|
|
|
*/ |
92
|
|
|
public function getLastName() |
93
|
|
|
{ |
94
|
|
|
return $this->getAttribute('lastName'); |
95
|
|
|
} |
96
|
6 |
|
|
97
|
|
|
/** |
98
|
6 |
|
* Get user userId |
99
|
|
|
* |
100
|
|
|
* @return string|null |
101
|
|
|
*/ |
102
|
|
|
public function getId() |
103
|
|
|
{ |
104
|
|
|
return $this->getAttribute('id'); |
105
|
|
|
} |
106
|
6 |
|
|
107
|
|
|
/** |
108
|
6 |
|
* Get user location |
109
|
|
|
* |
110
|
|
|
* @return string|null |
111
|
|
|
*/ |
112
|
|
|
public function getLocation() |
113
|
|
|
{ |
114
|
|
|
return $this->getAttribute('location.name'); |
115
|
|
|
} |
116
|
6 |
|
|
117
|
|
|
/** |
118
|
6 |
|
* Get user description |
119
|
|
|
* |
120
|
|
|
* @return string|null |
121
|
|
|
*/ |
122
|
|
|
public function getDescription() |
123
|
|
|
{ |
124
|
|
|
return $this->getAttribute('headline'); |
125
|
|
|
} |
126
|
6 |
|
|
127
|
|
|
/** |
128
|
6 |
|
* Get user url |
129
|
|
|
* |
130
|
|
|
* @return string|null |
131
|
|
|
*/ |
132
|
|
|
public function getUrl() |
133
|
|
|
{ |
134
|
|
|
return $this->getAttribute('publicProfileUrl'); |
135
|
|
|
} |
136
|
6 |
|
|
137
|
|
|
/** |
138
|
6 |
|
* Get user summary |
139
|
|
|
* |
140
|
|
|
* @return string|null |
141
|
|
|
*/ |
142
|
|
|
public function getSummary() |
143
|
|
|
{ |
144
|
|
|
return $this->getAttribute('summary'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Return all of the owner details available as an array. |
149
|
|
|
* |
150
|
|
|
* @return array |
151
|
|
|
*/ |
152
|
|
|
public function toArray() |
153
|
|
|
{ |
154
|
|
|
return $this->response; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|