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