| @@ 64-84 (lines=21) @@ | ||
| 61 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 62 | * @return TopSearchWidget Chainable |
|
| 63 | */ |
|
| 64 | public function setStartDate($date) |
|
| 65 | { |
|
| 66 | if ($date === null || $date === '') { |
|
| 67 | $this->startDate = new DateTime(self::DEFAULT_FROM_DATE); |
|
| 68 | return $this; |
|
| 69 | } |
|
| 70 | ||
| 71 | if (is_string($date)) { |
|
| 72 | $date = new DateTime($date); |
|
| 73 | } |
|
| 74 | ||
| 75 | if (!$date instanceof DateTimeInterface) { |
|
| 76 | throw new InvalidArgumentException( |
|
| 77 | 'Invalid "Start Date" value. Must be a date/time string or a DateTimeInterface object.' |
|
| 78 | ); |
|
| 79 | } |
|
| 80 | ||
| 81 | $this->startDate = $date; |
|
| 82 | ||
| 83 | return $this; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Retrieve the lower bound (exclusive) for a search's timestamp to filter by. |
|
| @@ 108-128 (lines=21) @@ | ||
| 105 | * @throws InvalidArgumentException If the date/time is invalid. |
|
| 106 | * @return TopSearchWidget Chainable |
|
| 107 | */ |
|
| 108 | public function setEndDate($date) |
|
| 109 | { |
|
| 110 | if ($date === null || $date === '') { |
|
| 111 | $this->endDate = new DateTime(self::DEFAULT_UNTIL_DATE); |
|
| 112 | return $this; |
|
| 113 | } |
|
| 114 | ||
| 115 | if (is_string($date)) { |
|
| 116 | $date = new DateTime($date); |
|
| 117 | } |
|
| 118 | ||
| 119 | if (!($date instanceof DateTimeInterface)) { |
|
| 120 | throw new InvalidArgumentException( |
|
| 121 | 'Invalid "End Date" value. Must be a date/time string or a DateTimeInterface object.' |
|
| 122 | ); |
|
| 123 | } |
|
| 124 | ||
| 125 | $this->endDate = $date; |
|
| 126 | ||
| 127 | return $this; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Retrieve the upper bound (inclusive) for a search's timestamp to filter by. |
|