1
|
|
|
<?php |
2
|
|
|
namespace Germania\Users; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
abstract class UserAbstract implements UserInterface |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
use UserIdAwareTrait; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
public $display_name; |
12
|
|
|
public $first_name; |
13
|
|
|
public $last_name; |
14
|
|
|
public $login_name; |
15
|
|
|
public $email; |
16
|
|
|
public $api_key; |
17
|
|
|
|
18
|
|
|
public $is_active; |
19
|
|
|
public $created; |
20
|
|
|
public $updated; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
|
24
|
|
|
public function __debugInfo() { |
25
|
|
|
$cdt = $this->getCreationDateTime(); |
26
|
|
|
return [ |
27
|
|
|
'ID' => $this->getId(), |
28
|
|
|
'FirstName' => $this->getFirstName(), |
29
|
|
|
'LastName' => $this->getLastName(), |
30
|
|
|
'DisplayName' => $this->getDisplayName(), |
31
|
|
|
'Email' => $this->getEmail(), |
32
|
|
|
'LoginName' => $this->getLoginName(), |
33
|
|
|
'isActive' => $this->isActive(), |
34
|
|
|
'Created' => ($cdt instanceOf \DateTime) ? $cdt->format("Y-m-d H:i:s") : $cdt |
35
|
|
|
]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Returns the user's full name |
41
|
|
|
*/ |
42
|
|
|
abstract public function getFullName(); |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return bool |
48
|
|
|
* @uses $is_active |
49
|
|
|
*/ |
50
|
50 |
|
public function isActive() |
51
|
|
|
{ |
52
|
50 |
|
return (bool) $this->is_active; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return DateTime |
|
|
|
|
58
|
|
|
*/ |
59
|
5 |
|
public function getCreationDateTime() |
60
|
|
|
{ |
61
|
5 |
|
if ($this->created) |
62
|
5 |
|
return \DateTime::createFromFormat( "Y-m-d H:i:s", $this->created ); |
|
|
|
|
63
|
5 |
|
return $this->created; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return DateTime |
69
|
|
|
*/ |
70
|
5 |
|
public function getLastUpdateDateTime() |
71
|
|
|
{ |
72
|
5 |
|
if ($this->updated) |
73
|
5 |
|
return \DateTime::createFromFormat( "Y-m-d H:i:s", $this->updated ); |
|
|
|
|
74
|
5 |
|
return $this->updated; |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @uses $display_name |
81
|
|
|
*/ |
82
|
20 |
|
public function setDisplayName($display_name) |
83
|
|
|
{ |
84
|
20 |
|
$this->display_name = $display_name; |
85
|
20 |
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return string |
92
|
|
|
* @uses $display_name |
93
|
|
|
*/ |
94
|
20 |
|
public function getDisplayName() |
95
|
|
|
{ |
96
|
20 |
|
return $this->display_name; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
|
101
|
|
|
|
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param string $name |
109
|
|
|
* @return self |
110
|
|
|
* @uses $first_name |
111
|
|
|
*/ |
112
|
5 |
|
public function setFirstName($name) |
113
|
|
|
{ |
114
|
5 |
|
$this->first_name = $name; |
115
|
5 |
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @uses $first_name |
121
|
|
|
*/ |
122
|
5 |
|
public function getFirstName() |
123
|
|
|
{ |
124
|
5 |
|
return $this->first_name; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
|
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param string $name |
132
|
|
|
* @return self |
133
|
|
|
* @uses $last_name |
134
|
|
|
*/ |
135
|
5 |
|
public function setLastName($name) |
136
|
|
|
{ |
137
|
5 |
|
$this->last_name = $name; |
138
|
5 |
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @uses $last_name |
144
|
|
|
*/ |
145
|
5 |
|
public function getLastName() |
146
|
|
|
{ |
147
|
5 |
|
return $this->last_name; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
|
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param string $name |
155
|
|
|
* @return self |
156
|
|
|
* @uses $login_name |
157
|
|
|
*/ |
158
|
20 |
|
public function setLoginName($name) |
159
|
|
|
{ |
160
|
20 |
|
$this->login_name = $name; |
161
|
20 |
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @uses $login_name |
167
|
|
|
*/ |
168
|
10 |
|
public function getLoginName() |
169
|
|
|
{ |
170
|
10 |
|
return $this->login_name; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
|
175
|
|
|
|
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param mixed $email |
179
|
|
|
* @return self |
180
|
|
|
*/ |
181
|
5 |
|
public function setEmail( $email) |
182
|
|
|
{ |
183
|
5 |
|
$this->email = $email; |
184
|
5 |
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @uses $email |
190
|
|
|
*/ |
191
|
5 |
|
public function getEmail() |
192
|
|
|
{ |
193
|
5 |
|
return $this->email; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Returns the users API key (if defined) |
200
|
|
|
* |
201
|
|
|
* @return string|null |
202
|
|
|
* @uses $api_key |
203
|
|
|
*/ |
204
|
5 |
|
public function getApiKey() |
205
|
|
|
{ |
206
|
5 |
|
return $this->api_key; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
|
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Sets the users API key |
213
|
|
|
* |
214
|
|
|
* @return self |
215
|
|
|
* @uses $api_key |
216
|
|
|
*/ |
217
|
5 |
|
public function setApiKey( $key ) |
218
|
|
|
{ |
219
|
5 |
|
$this->api_key = $key; |
220
|
5 |
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
|
224
|
|
|
|
225
|
|
|
} |
226
|
|
|
|