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