@@ 233-260 (lines=28) @@ | ||
230 | * @throws InvalidArgumentException If the ts is not a valid date/time. |
|
231 | * @return UserInterface Chainable |
|
232 | */ |
|
233 | public function setLastLoginDate($lastLoginDate) |
|
234 | { |
|
235 | if ($lastLoginDate === null) { |
|
236 | $this->lastLoginDate = null; |
|
237 | return $this; |
|
238 | } |
|
239 | ||
240 | if (is_string($lastLoginDate)) { |
|
241 | try { |
|
242 | $lastLoginDate = new DateTime($lastLoginDate); |
|
243 | } catch (Exception $e) { |
|
244 | throw new InvalidArgumentException(sprintf( |
|
245 | 'Invalid login date (%s)', |
|
246 | $e->getMessage() |
|
247 | ), 0, $e); |
|
248 | } |
|
249 | } |
|
250 | ||
251 | if (!($lastLoginDate instanceof DateTimeInterface)) { |
|
252 | throw new InvalidArgumentException( |
|
253 | 'Invalid "Last Login Date" value. Must be a date/time string or a DateTime object.' |
|
254 | ); |
|
255 | } |
|
256 | ||
257 | $this->lastLoginDate = $lastLoginDate; |
|
258 | ||
259 | return $this; |
|
260 | } |
|
261 | ||
262 | /** |
|
263 | * @return DateTimeInterface|null |
|
@@ 312-339 (lines=28) @@ | ||
309 | * @throws InvalidArgumentException If the passsword date is not a valid DateTime. |
|
310 | * @return UserInterface Chainable |
|
311 | */ |
|
312 | public function setLastPasswordDate($lastPasswordDate) |
|
313 | { |
|
314 | if ($lastPasswordDate === null) { |
|
315 | $this->lastPasswordDate = null; |
|
316 | return $this; |
|
317 | } |
|
318 | ||
319 | if (is_string($lastPasswordDate)) { |
|
320 | try { |
|
321 | $lastPasswordDate = new DateTime($lastPasswordDate); |
|
322 | } catch (Exception $e) { |
|
323 | throw new InvalidArgumentException(sprintf( |
|
324 | 'Invalid last password date (%s)', |
|
325 | $e->getMessage() |
|
326 | ), 0, $e); |
|
327 | } |
|
328 | } |
|
329 | ||
330 | if (!($lastPasswordDate instanceof DateTimeInterface)) { |
|
331 | throw new InvalidArgumentException( |
|
332 | 'Invalid "Last Password Date" value. Must be a date/time string or a DateTime object.' |
|
333 | ); |
|
334 | } |
|
335 | ||
336 | $this->lastPasswordDate = $lastPasswordDate; |
|
337 | ||
338 | return $this; |
|
339 | } |
|
340 | ||
341 | /** |
|
342 | * @return DateTimeInterface|null |