| @@ 164-190 (lines=27) @@ | ||
| 161 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 162 | * @return self |
|
| 163 | */ |
|
| 164 | public function setQueuedDate($ts) |
|
| 165 | { |
|
| 166 | if ($ts === null) { |
|
| 167 | $this->queuedDate = null; |
|
| 168 | return $this; |
|
| 169 | } |
|
| 170 | ||
| 171 | if (is_string($ts)) { |
|
| 172 | try { |
|
| 173 | $ts = new DateTime($ts); |
|
| 174 | } catch (Exception $e) { |
|
| 175 | throw new InvalidArgumentException( |
|
| 176 | sprintf('Can not set queued date: %s', $e->getMessage()) |
|
| 177 | ); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||
| 181 | if (!($ts instanceof DateTimeInterface)) { |
|
| 182 | throw new InvalidArgumentException( |
|
| 183 | 'Invalid "Queued Date" value. Must be a date/time string or a DateTime object.' |
|
| 184 | ); |
|
| 185 | } |
|
| 186 | ||
| 187 | $this->queuedDate = $ts; |
|
| 188 | ||
| 189 | return $this; |
|
| 190 | } |
|
| 191 | ||
| 192 | /** |
|
| 193 | * Retrieve the date/time the item was queued at. |
|
| @@ 209-235 (lines=27) @@ | ||
| 206 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 207 | * @return self |
|
| 208 | */ |
|
| 209 | public function setProcessingDate($ts) |
|
| 210 | { |
|
| 211 | if ($ts === null) { |
|
| 212 | $this->processingDate = null; |
|
| 213 | return $this; |
|
| 214 | } |
|
| 215 | ||
| 216 | if (is_string($ts)) { |
|
| 217 | try { |
|
| 218 | $ts = new DateTime($ts); |
|
| 219 | } catch (Exception $e) { |
|
| 220 | throw new InvalidArgumentException( |
|
| 221 | sprintf('%s (%s)', $e->getMessage(), $ts) |
|
| 222 | ); |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | if (!($ts instanceof DateTimeInterface)) { |
|
| 227 | throw new InvalidArgumentException( |
|
| 228 | 'Invalid "Processing Date" value. Must be a date/time string or a DateTime object.' |
|
| 229 | ); |
|
| 230 | } |
|
| 231 | ||
| 232 | $this->processingDate = $ts; |
|
| 233 | ||
| 234 | return $this; |
|
| 235 | } |
|
| 236 | ||
| 237 | /** |
|
| 238 | * Retrieve the date/time the item should be processed at. |
|
| @@ 254-280 (lines=27) @@ | ||
| 251 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 252 | * @return self |
|
| 253 | */ |
|
| 254 | public function setProcessedDate($ts) |
|
| 255 | { |
|
| 256 | if ($ts === null) { |
|
| 257 | $this->processedDate = null; |
|
| 258 | return $this; |
|
| 259 | } |
|
| 260 | ||
| 261 | if (is_string($ts)) { |
|
| 262 | try { |
|
| 263 | $ts = new DateTime($ts); |
|
| 264 | } catch (Exception $e) { |
|
| 265 | throw new InvalidArgumentException( |
|
| 266 | sprintf('%s (%s)', $e->getMessage(), $ts) |
|
| 267 | ); |
|
| 268 | } |
|
| 269 | } |
|
| 270 | ||
| 271 | if (!($ts instanceof DateTimeInterface)) { |
|
| 272 | throw new InvalidArgumentException( |
|
| 273 | 'Invalid "Processed Date" value. Must be a date/time string or a DateTime object.' |
|
| 274 | ); |
|
| 275 | } |
|
| 276 | ||
| 277 | $this->processedDate = $ts; |
|
| 278 | ||
| 279 | return $this; |
|
| 280 | } |
|
| 281 | ||
| 282 | /** |
|
| 283 | * Retrieve the date/time the item was processed at. |
|
| @@ 309-335 (lines=27) @@ | ||
| 306 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 307 | * @return self |
|
| 308 | */ |
|
| 309 | public function setExpiryDate($ts) |
|
| 310 | { |
|
| 311 | if ($ts === null) { |
|
| 312 | $this->expiryDate = null; |
|
| 313 | return $this; |
|
| 314 | } |
|
| 315 | ||
| 316 | if (is_string($ts)) { |
|
| 317 | try { |
|
| 318 | $ts = new DateTime($ts); |
|
| 319 | } catch (Exception $e) { |
|
| 320 | throw new InvalidArgumentException( |
|
| 321 | sprintf('%s (%s)', $e->getMessage(), $ts) |
|
| 322 | ); |
|
| 323 | } |
|
| 324 | } |
|
| 325 | ||
| 326 | if (!($ts instanceof DateTimeInterface)) { |
|
| 327 | throw new InvalidArgumentException( |
|
| 328 | 'Invalid "Expiry Date" value. Must be a date/time string or a DateTime object.' |
|
| 329 | ); |
|
| 330 | } |
|
| 331 | ||
| 332 | $this->expiryDate = $ts; |
|
| 333 | ||
| 334 | return $this; |
|
| 335 | } |
|
| 336 | ||
| 337 | /** |
|
| 338 | * Hook called before saving the item. |
|