Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
8 */ | 8 */ |
9 | 9 |
10 namespace Zend\Feed\Writer; | 10 namespace Zend\Feed\Writer; |
11 | 11 |
12 use DateTime; | 12 use DateTime; |
13 use DateTimeInterface; | |
13 use Zend\Feed\Uri; | 14 use Zend\Feed\Uri; |
14 use Zend\Validator; | 15 use Zend\Validator; |
15 | 16 |
16 class AbstractFeed | 17 class AbstractFeed |
17 { | 18 { |
126 } | 127 } |
127 | 128 |
128 /** | 129 /** |
129 * Set the feed creation date | 130 * Set the feed creation date |
130 * | 131 * |
131 * @param null|int|DateTime | 132 * @param null|int|DateTimeInterface |
132 * @throws Exception\InvalidArgumentException | 133 * @throws Exception\InvalidArgumentException |
133 * @return AbstractFeed | 134 * @return AbstractFeed |
134 */ | 135 */ |
135 public function setDateCreated($date = null) | 136 public function setDateCreated($date = null) |
136 { | 137 { |
137 if ($date === null) { | 138 if ($date === null) { |
138 $date = new DateTime(); | 139 $date = new DateTime(); |
139 } elseif (is_int($date)) { | 140 } |
141 if (is_int($date)) { | |
140 $date = new DateTime('@' . $date); | 142 $date = new DateTime('@' . $date); |
141 } elseif (! $date instanceof DateTime) { | 143 } |
144 if (! $date instanceof DateTimeInterface) { | |
142 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' | 145 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' |
143 . ' passed as parameter'); | 146 . ' passed as parameter'); |
144 } | 147 } |
145 $this->data['dateCreated'] = $date; | 148 $this->data['dateCreated'] = $date; |
146 | 149 |
148 } | 151 } |
149 | 152 |
150 /** | 153 /** |
151 * Set the feed modification date | 154 * Set the feed modification date |
152 * | 155 * |
153 * @param null|int|DateTime | 156 * @param null|int|DateTimeInterface |
154 * @throws Exception\InvalidArgumentException | 157 * @throws Exception\InvalidArgumentException |
155 * @return AbstractFeed | 158 * @return AbstractFeed |
156 */ | 159 */ |
157 public function setDateModified($date = null) | 160 public function setDateModified($date = null) |
158 { | 161 { |
159 if ($date === null) { | 162 if ($date === null) { |
160 $date = new DateTime(); | 163 $date = new DateTime(); |
161 } elseif (is_int($date)) { | 164 } |
165 if (is_int($date)) { | |
162 $date = new DateTime('@' . $date); | 166 $date = new DateTime('@' . $date); |
163 } elseif (! $date instanceof DateTime) { | 167 } |
168 if (! $date instanceof DateTimeInterface) { | |
164 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' | 169 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' |
165 . ' passed as parameter'); | 170 . ' passed as parameter'); |
166 } | 171 } |
167 $this->data['dateModified'] = $date; | 172 $this->data['dateModified'] = $date; |
168 | 173 |
170 } | 175 } |
171 | 176 |
172 /** | 177 /** |
173 * Set the feed last-build date. Ignored for Atom 1.0. | 178 * Set the feed last-build date. Ignored for Atom 1.0. |
174 * | 179 * |
175 * @param null|int|DateTime | 180 * @param null|int|DateTimeInterface |
176 * @throws Exception\InvalidArgumentException | 181 * @throws Exception\InvalidArgumentException |
177 * @return AbstractFeed | 182 * @return AbstractFeed |
178 */ | 183 */ |
179 public function setLastBuildDate($date = null) | 184 public function setLastBuildDate($date = null) |
180 { | 185 { |
181 if ($date === null) { | 186 if ($date === null) { |
182 $date = new DateTime(); | 187 $date = new DateTime(); |
183 } elseif (is_int($date)) { | 188 } |
189 if (is_int($date)) { | |
184 $date = new DateTime('@' . $date); | 190 $date = new DateTime('@' . $date); |
185 } elseif (! $date instanceof DateTime) { | 191 } |
192 if (! $date instanceof DateTimeInterface) { | |
186 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' | 193 throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp' |
187 . ' passed as parameter'); | 194 . ' passed as parameter'); |
188 } | 195 } |
189 $this->data['lastBuildDate'] = $date; | 196 $this->data['lastBuildDate'] = $date; |
190 | 197 |
562 } | 569 } |
563 | 570 |
564 /** | 571 /** |
565 * Get an array with feed authors | 572 * Get an array with feed authors |
566 * | 573 * |
567 * @return array | 574 * @return array|null |
568 */ | 575 */ |
569 public function getAuthors() | 576 public function getAuthors() |
570 { | 577 { |
571 if (! array_key_exists('authors', $this->data)) { | 578 if (! array_key_exists('authors', $this->data)) { |
572 return; | 579 return; |