1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 Facebook, Inc. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
*/ |
23
|
|
|
namespace Facebook\GraphNode; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @package Facebook |
27
|
|
|
*/ |
28
|
|
|
class GraphUser extends GraphNode |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var array maps object key names to Graph object types |
32
|
|
|
*/ |
33
|
|
|
protected static $graphNodeMap = [ |
34
|
|
|
'hometown' => GraphPage::class, |
35
|
|
|
'location' => GraphPage::class, |
36
|
|
|
'significant_other' => GraphUser::class, |
37
|
|
|
'picture' => GraphPicture::class, |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Returns the ID for the user as a string if present. |
42
|
|
|
* |
43
|
|
|
* @return null|string |
44
|
|
|
*/ |
45
|
|
|
public function getId() |
46
|
|
|
{ |
47
|
|
|
return $this->getField('id'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns the name for the user as a string if present. |
52
|
|
|
* |
53
|
|
|
* @return null|string |
54
|
|
|
*/ |
55
|
|
|
public function getName() |
56
|
|
|
{ |
57
|
|
|
return $this->getField('name'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Returns the first name for the user as a string if present. |
62
|
|
|
* |
63
|
|
|
* @return null|string |
64
|
|
|
*/ |
65
|
|
|
public function getFirstName() |
66
|
|
|
{ |
67
|
|
|
return $this->getField('first_name'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns the middle name for the user as a string if present. |
72
|
|
|
* |
73
|
|
|
* @return null|string |
74
|
|
|
*/ |
75
|
|
|
public function getMiddleName() |
76
|
|
|
{ |
77
|
|
|
return $this->getField('middle_name'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Returns the last name for the user as a string if present. |
82
|
|
|
* |
83
|
|
|
* @return null|string |
84
|
|
|
*/ |
85
|
|
|
public function getLastName() |
86
|
|
|
{ |
87
|
|
|
return $this->getField('last_name'); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns the email for the user as a string if present. |
92
|
|
|
* |
93
|
|
|
* @return null|string |
94
|
|
|
*/ |
95
|
|
|
public function getEmail() |
96
|
|
|
{ |
97
|
|
|
return $this->getField('email'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Returns the gender for the user as a string if present. |
102
|
|
|
* |
103
|
|
|
* @return null|string |
104
|
|
|
*/ |
105
|
|
|
public function getGender() |
106
|
|
|
{ |
107
|
|
|
return $this->getField('gender'); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Returns the Facebook URL for the user as a string if available. |
112
|
|
|
* |
113
|
|
|
* @return null|string |
114
|
|
|
*/ |
115
|
|
|
public function getLink() |
116
|
|
|
{ |
117
|
|
|
return $this->getField('link'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Returns the users birthday, if available. |
122
|
|
|
* |
123
|
|
|
* @return null|Birthday |
124
|
|
|
*/ |
125
|
3 |
|
public function getBirthday() |
126
|
|
|
{ |
127
|
3 |
|
return $this->getField('birthday'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Returns the current location of the user as a GraphPage. |
132
|
|
|
* |
133
|
|
|
* @return null|GraphPage |
134
|
|
|
*/ |
135
|
1 |
|
public function getLocation() |
136
|
|
|
{ |
137
|
1 |
|
return $this->getField('location'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Returns the current location of the user as a GraphPage. |
142
|
|
|
* |
143
|
|
|
* @return null|GraphPage |
144
|
|
|
*/ |
145
|
1 |
|
public function getHometown() |
146
|
|
|
{ |
147
|
1 |
|
return $this->getField('hometown'); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Returns the current location of the user as a GraphUser. |
152
|
|
|
* |
153
|
|
|
* @return null|GraphUser |
154
|
|
|
*/ |
155
|
1 |
|
public function getSignificantOther() |
156
|
|
|
{ |
157
|
1 |
|
return $this->getField('significant_other'); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Returns the picture of the user as a GraphPicture. |
162
|
|
|
* |
163
|
|
|
* @return null|GraphPicture |
164
|
|
|
*/ |
165
|
1 |
|
public function getPicture() |
166
|
|
|
{ |
167
|
1 |
|
return $this->getField('picture'); |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|