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