| @@ 269-289 (lines=21) @@ | ||
| 266 | * @throws InvalidArgumentException If the IP is not an IP string, an integer, or null. |
|
| 267 | * @return UserInterface Chainable |
|
| 268 | */ |
|
| 269 | public function setLastLoginIp($ip) |
|
| 270 | { |
|
| 271 | if ($ip === null) { |
|
| 272 | $this->lastLoginIp = null; |
|
| 273 | return $this; |
|
| 274 | } |
|
| 275 | ||
| 276 | if (is_int($ip)) { |
|
| 277 | $ip = long2ip($ip); |
|
| 278 | } |
|
| 279 | ||
| 280 | if (!is_string($ip)) { |
|
| 281 | throw new InvalidArgumentException( |
|
| 282 | 'Invalid IP address' |
|
| 283 | ); |
|
| 284 | } |
|
| 285 | ||
| 286 | $this->lastLoginIp = $ip; |
|
| 287 | ||
| 288 | return $this; |
|
| 289 | } |
|
| 290 | ||
| 291 | /** |
|
| 292 | * Get the last login IP in x.x.x.x format |
|
| @@ 348-368 (lines=21) @@ | ||
| 345 | * @throws InvalidArgumentException If the IP is not null, an integer or an IP string. |
|
| 346 | * @return UserInterface Chainable |
|
| 347 | */ |
|
| 348 | public function setLastPasswordIp($ip) |
|
| 349 | { |
|
| 350 | if ($ip === null) { |
|
| 351 | $this->lastPasswordIp = null; |
|
| 352 | return $this; |
|
| 353 | } |
|
| 354 | ||
| 355 | if (is_int($ip)) { |
|
| 356 | $ip = long2ip($ip); |
|
| 357 | } |
|
| 358 | ||
| 359 | if (!is_string($ip)) { |
|
| 360 | throw new InvalidArgumentException( |
|
| 361 | 'Invalid IP address' |
|
| 362 | ); |
|
| 363 | } |
|
| 364 | ||
| 365 | $this->lastPasswordIp = $ip; |
|
| 366 | ||
| 367 | return $this; |
|
| 368 | } |
|
| 369 | ||
| 370 | /** |
|
| 371 | * Get the last password change IP in x.x.x.x format |
|
| @@ 128-144 (lines=17) @@ | ||
| 125 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 126 | * @return AuthToken Chainable |
|
| 127 | */ |
|
| 128 | public function setExpiry($expiry) |
|
| 129 | { |
|
| 130 | if ($expiry === null) { |
|
| 131 | $this->expiry = null; |
|
| 132 | return $this; |
|
| 133 | } |
|
| 134 | if (is_string($expiry)) { |
|
| 135 | $expiry = new DateTime($expiry); |
|
| 136 | } |
|
| 137 | if (!($expiry instanceof DateTimeInterface)) { |
|
| 138 | throw new InvalidArgumentException( |
|
| 139 | 'Invalid "Expiry" value. Must be a date/time string or a DateTime object.' |
|
| 140 | ); |
|
| 141 | } |
|
| 142 | $this->expiry = $expiry; |
|
| 143 | return $this; |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * @return DateTimeInterface|null |
|
| @@ 159-175 (lines=17) @@ | ||
| 156 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 157 | * @return AuthToken Chainable |
|
| 158 | */ |
|
| 159 | public function setCreated($created) |
|
| 160 | { |
|
| 161 | if ($created === null) { |
|
| 162 | $this->created = null; |
|
| 163 | return $this; |
|
| 164 | } |
|
| 165 | if (is_string($created)) { |
|
| 166 | $created = new DateTime($created); |
|
| 167 | } |
|
| 168 | if (!($created instanceof DateTimeInterface)) { |
|
| 169 | throw new InvalidArgumentException( |
|
| 170 | 'Invalid "Created" value. Must be a date/time string or a DateTime object.' |
|
| 171 | ); |
|
| 172 | } |
|
| 173 | $this->created = $created; |
|
| 174 | return $this; |
|
| 175 | } |
|
| 176 | ||
| 177 | /** |
|
| 178 | * @return DateTimeInterface|null |
|
| @@ 190-206 (lines=17) @@ | ||
| 187 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 188 | * @return AuthToken Chainable |
|
| 189 | */ |
|
| 190 | public function setLastModified($lastModified) |
|
| 191 | { |
|
| 192 | if ($lastModified === null) { |
|
| 193 | $this->lastModified = null; |
|
| 194 | return $this; |
|
| 195 | } |
|
| 196 | if (is_string($lastModified)) { |
|
| 197 | $lastModified = new DateTime($lastModified); |
|
| 198 | } |
|
| 199 | if (!($lastModified instanceof DateTimeInterface)) { |
|
| 200 | throw new InvalidArgumentException( |
|
| 201 | 'Invalid "Last Modified" value. Must be a date/time string or a DateTime object.' |
|
| 202 | ); |
|
| 203 | } |
|
| 204 | $this->lastModified = $lastModified; |
|
| 205 | return $this; |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * @return DateTimeInterface|null |
|