@@ 219-247 (lines=29) @@ | ||
216 | * @throws InvalidArgumentException If the date/time is invalid. |
|
217 | * @return ObjectScheduleInterface Chainable |
|
218 | */ |
|
219 | public function setScheduledDate($ts) |
|
220 | { |
|
221 | if ($ts === null) { |
|
222 | $this->scheduledDate = null; |
|
223 | return $this; |
|
224 | } |
|
225 | ||
226 | if (is_string($ts)) { |
|
227 | try { |
|
228 | $ts = new DateTime($ts); |
|
229 | } catch (Exception $e) { |
|
230 | throw new InvalidArgumentException(sprintf( |
|
231 | '%s (%s)', |
|
232 | $e->getMessage(), |
|
233 | $ts |
|
234 | ), 0, $e); |
|
235 | } |
|
236 | } |
|
237 | ||
238 | if (!($ts instanceof DateTimeInterface)) { |
|
239 | throw new InvalidArgumentException( |
|
240 | 'Invalid "Processing Date" value. Must be a date/time string or a DateTime object.' |
|
241 | ); |
|
242 | } |
|
243 | ||
244 | $this->scheduledDate = $ts; |
|
245 | ||
246 | return $this; |
|
247 | } |
|
248 | ||
249 | /** |
|
250 | * Retrieve the date/time the item should be processed at. |
|
@@ 266-294 (lines=29) @@ | ||
263 | * @throws InvalidArgumentException If the date/time is invalid. |
|
264 | * @return ObjectScheduleInterface Chainable |
|
265 | */ |
|
266 | public function setProcessedDate($ts) |
|
267 | { |
|
268 | if ($ts === null) { |
|
269 | $this->processedDate = null; |
|
270 | return $this; |
|
271 | } |
|
272 | ||
273 | if (is_string($ts)) { |
|
274 | try { |
|
275 | $ts = new DateTime($ts); |
|
276 | } catch (Exception $e) { |
|
277 | throw new InvalidArgumentException(sprintf( |
|
278 | '%s (%s)', |
|
279 | $e->getMessage(), |
|
280 | $ts |
|
281 | ), 0, $e); |
|
282 | } |
|
283 | } |
|
284 | ||
285 | if (!($ts instanceof DateTimeInterface)) { |
|
286 | throw new InvalidArgumentException( |
|
287 | 'Invalid "Processed Date" value. Must be a date/time string or a DateTime object.' |
|
288 | ); |
|
289 | } |
|
290 | ||
291 | $this->processedDate = $ts; |
|
292 | ||
293 | return $this; |
|
294 | } |
|
295 | ||
296 | /** |
|
297 | * Retrieve the date/time the item was processed at. |
@@ 47-74 (lines=28) @@ | ||
44 | * @throws InvalidArgumentException If the value is not a date/time instance. |
|
45 | * @return PublishableInterface Chainable |
|
46 | */ |
|
47 | public function setPublishDate($time) |
|
48 | { |
|
49 | if ($time === null || $time === '') { |
|
50 | $this->publishDate = null; |
|
51 | return $this; |
|
52 | } |
|
53 | ||
54 | if (is_string($time)) { |
|
55 | try { |
|
56 | $time = new DateTime($time); |
|
57 | } catch (Exception $e) { |
|
58 | throw new UnexpectedValueException(sprintf( |
|
59 | 'Invalid Publication Date: %s', |
|
60 | $e->getMessage() |
|
61 | ), $e->getCode(), $e); |
|
62 | } |
|
63 | } |
|
64 | ||
65 | if (!$time instanceof DateTimeInterface) { |
|
66 | throw new InvalidArgumentException( |
|
67 | 'Publication Date must be a date/time string or an instance of DateTimeInterface' |
|
68 | ); |
|
69 | } |
|
70 | ||
71 | $this->publishDate = $time; |
|
72 | ||
73 | return $this; |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * Retrieve the object's publication date. |
|
@@ 94-121 (lines=28) @@ | ||
91 | * @throws InvalidArgumentException If the value is not a date/time instance. |
|
92 | * @return PublishableInterface Chainable |
|
93 | */ |
|
94 | public function setExpiryDate($time) |
|
95 | { |
|
96 | if ($time === null || $time === '') { |
|
97 | $this->expiryDate = null; |
|
98 | return $this; |
|
99 | } |
|
100 | ||
101 | if (is_string($time)) { |
|
102 | try { |
|
103 | $time = new DateTime($time); |
|
104 | } catch (Exception $e) { |
|
105 | throw new UnexpectedValueException(sprintf( |
|
106 | 'Invalid Expiration Date: %s', |
|
107 | $e->getMessage() |
|
108 | ), $e->getCode(), $e); |
|
109 | } |
|
110 | } |
|
111 | ||
112 | if (!$time instanceof DateTimeInterface) { |
|
113 | throw new InvalidArgumentException( |
|
114 | 'Expiration Date must be a date/time string or an instance of DateTimeInterface' |
|
115 | ); |
|
116 | } |
|
117 | ||
118 | $this->expiryDate = $time; |
|
119 | ||
120 | return $this; |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * Retrieve the object's expiration date. |
@@ 204-231 (lines=28) @@ | ||
201 | * @throws InvalidArgumentException If the timestamp is invalid. |
|
202 | * @return self |
|
203 | */ |
|
204 | public function setTs($timestamp) |
|
205 | { |
|
206 | if ($timestamp === null) { |
|
207 | $this->ts = null; |
|
208 | return $this; |
|
209 | } |
|
210 | ||
211 | if (is_string($timestamp)) { |
|
212 | try { |
|
213 | $timestamp = new DateTime($timestamp); |
|
214 | } catch (Exception $e) { |
|
215 | throw new InvalidArgumentException(sprintf( |
|
216 | 'Invalid timestamp: %s', |
|
217 | $e->getMessage() |
|
218 | ), 0, $e); |
|
219 | } |
|
220 | } |
|
221 | ||
222 | if (!$timestamp instanceof DateTimeInterface) { |
|
223 | throw new InvalidArgumentException( |
|
224 | 'Invalid timestamp value. Must be a date/time string or a DateTime object.' |
|
225 | ); |
|
226 | } |
|
227 | ||
228 | $this->ts = $timestamp; |
|
229 | ||
230 | return $this; |
|
231 | } |
|
232 | ||
233 | /** |
|
234 | * Retrieve the creation timestamp. |