Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
75 * @return Feed | 75 * @return Feed |
76 * @throws Writer\Exception\InvalidArgumentException | 76 * @throws Writer\Exception\InvalidArgumentException |
77 */ | 77 */ |
78 public function setItunesBlock($value) | 78 public function setItunesBlock($value) |
79 { | 79 { |
80 if (!ctype_alpha($value) && strlen($value) > 0) { | 80 if (! ctype_alpha($value) && strlen($value) > 0) { |
81 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' | 81 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' |
82 . ' contain alphabetic characters'); | 82 . ' contain alphabetic characters'); |
83 } | 83 } |
84 if ($this->stringWrapper->strlen($value) > 255) { | 84 if ($this->stringWrapper->strlen($value) > 255) { |
85 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' | 85 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' |
114 { | 114 { |
115 if ($this->stringWrapper->strlen($value) > 255) { | 115 if ($this->stringWrapper->strlen($value) > 255) { |
116 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only' | 116 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only' |
117 . ' contain a maximum of 255 characters each'); | 117 . ' contain a maximum of 255 characters each'); |
118 } | 118 } |
119 if (!isset($this->data['authors'])) { | 119 if (! isset($this->data['authors'])) { |
120 $this->data['authors'] = []; | 120 $this->data['authors'] = []; |
121 } | 121 } |
122 $this->data['authors'][] = $value; | 122 $this->data['authors'][] = $value; |
123 return $this; | 123 return $this; |
124 } | 124 } |
130 * @return Feed | 130 * @return Feed |
131 * @throws Writer\Exception\InvalidArgumentException | 131 * @throws Writer\Exception\InvalidArgumentException |
132 */ | 132 */ |
133 public function setItunesCategories(array $values) | 133 public function setItunesCategories(array $values) |
134 { | 134 { |
135 if (!isset($this->data['categories'])) { | 135 if (! isset($this->data['categories'])) { |
136 $this->data['categories'] = []; | 136 $this->data['categories'] = []; |
137 } | 137 } |
138 foreach ($values as $key => $value) { | 138 foreach ($values as $key => $value) { |
139 if (!is_array($value)) { | 139 if (! is_array($value)) { |
140 if ($this->stringWrapper->strlen($value) > 255) { | 140 if ($this->stringWrapper->strlen($value) > 255) { |
141 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' | 141 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only' |
142 . ' contain a maximum of 255 characters each'); | 142 . ' contain a maximum of 255 characters each'); |
143 } | 143 } |
144 $this->data['categories'][] = $value; | 144 $this->data['categories'][] = $value; |
167 * @return Feed | 167 * @return Feed |
168 * @throws Writer\Exception\InvalidArgumentException | 168 * @throws Writer\Exception\InvalidArgumentException |
169 */ | 169 */ |
170 public function setItunesImage($value) | 170 public function setItunesImage($value) |
171 { | 171 { |
172 if (!Uri::factory($value)->isValid()) { | 172 if (! Uri::factory($value)->isValid()) { |
173 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' | 173 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' |
174 . ' be a valid URI/IRI'); | 174 . ' be a valid URI/IRI'); |
175 } | 175 } |
176 if (!in_array(substr($value, -3), ['jpg', 'png'])) { | 176 if (! in_array(substr($value, -3), ['jpg', 'png'])) { |
177 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' | 177 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only' |
178 . ' use file extension "jpg" or "png" which must be the last three' | 178 . ' use file extension "jpg" or "png" which must be the last three' |
179 . ' characters of the URI (i.e. no query string or fragment)'); | 179 . ' characters of the URI (i.e. no query string or fragment)'); |
180 } | 180 } |
181 $this->data['image'] = $value; | 181 $this->data['image'] = $value; |
190 * @throws Writer\Exception\InvalidArgumentException | 190 * @throws Writer\Exception\InvalidArgumentException |
191 */ | 191 */ |
192 public function setItunesDuration($value) | 192 public function setItunesDuration($value) |
193 { | 193 { |
194 $value = (string) $value; | 194 $value = (string) $value; |
195 if (!ctype_digit($value) | 195 if (! ctype_digit($value) |
196 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) | 196 && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) |
197 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) | 197 && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) |
198 ) { | 198 ) { |
199 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only' | 199 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only' |
200 . ' be of a specified [[HH:]MM:]SS format'); | 200 . ' be of a specified [[HH:]MM:]SS format'); |
201 } | 201 } |
202 $this->data['duration'] = $value; | 202 $this->data['duration'] = $value; |
210 * @return Feed | 210 * @return Feed |
211 * @throws Writer\Exception\InvalidArgumentException | 211 * @throws Writer\Exception\InvalidArgumentException |
212 */ | 212 */ |
213 public function setItunesExplicit($value) | 213 public function setItunesExplicit($value) |
214 { | 214 { |
215 if (!in_array($value, ['yes', 'no', 'clean'])) { | 215 if (! in_array($value, ['yes', 'no', 'clean'])) { |
216 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only' | 216 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only' |
217 . ' be one of "yes", "no" or "clean"'); | 217 . ' be one of "yes", "no" or "clean"'); |
218 } | 218 } |
219 $this->data['explicit'] = $value; | 219 $this->data['explicit'] = $value; |
220 return $this; | 220 return $this; |
250 * @return Feed | 250 * @return Feed |
251 * @throws Writer\Exception\InvalidArgumentException | 251 * @throws Writer\Exception\InvalidArgumentException |
252 */ | 252 */ |
253 public function setItunesNewFeedUrl($value) | 253 public function setItunesNewFeedUrl($value) |
254 { | 254 { |
255 if (!Uri::factory($value)->isValid()) { | 255 if (! Uri::factory($value)->isValid()) { |
256 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "newFeedUrl" may only' | 256 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "newFeedUrl" may only' |
257 . ' be a valid URI/IRI'); | 257 . ' be a valid URI/IRI'); |
258 } | 258 } |
259 $this->data['newFeedUrl'] = $value; | 259 $this->data['newFeedUrl'] = $value; |
260 return $this; | 260 return $this; |
281 * @return Feed | 281 * @return Feed |
282 * @throws Writer\Exception\InvalidArgumentException | 282 * @throws Writer\Exception\InvalidArgumentException |
283 */ | 283 */ |
284 public function addItunesOwner(array $value) | 284 public function addItunesOwner(array $value) |
285 { | 285 { |
286 if (!isset($value['name']) || !isset($value['email'])) { | 286 if (! isset($value['name']) || ! isset($value['email'])) { |
287 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" must' | 287 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" must' |
288 . ' be an array containing keys "name" and "email"'); | 288 . ' be an array containing keys "name" and "email"'); |
289 } | 289 } |
290 if ($this->stringWrapper->strlen($value['name']) > 255 | 290 if ($this->stringWrapper->strlen($value['name']) > 255 |
291 || $this->stringWrapper->strlen($value['email']) > 255 | 291 || $this->stringWrapper->strlen($value['email']) > 255 |
292 ) { | 292 ) { |
293 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" may only' | 293 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" may only' |
294 . ' contain a maximum of 255 characters each for "name" and "email"'); | 294 . ' contain a maximum of 255 characters each for "name" and "email"'); |
295 } | 295 } |
296 if (!isset($this->data['owners'])) { | 296 if (! isset($this->data['owners'])) { |
297 $this->data['owners'] = []; | 297 $this->data['owners'] = []; |
298 } | 298 } |
299 $this->data['owners'][] = $value; | 299 $this->data['owners'][] = $value; |
300 return $this; | 300 return $this; |
301 } | 301 } |
343 * @throws Writer\Exception\BadMethodCallException | 343 * @throws Writer\Exception\BadMethodCallException |
344 */ | 344 */ |
345 public function __call($method, array $params) | 345 public function __call($method, array $params) |
346 { | 346 { |
347 $point = lcfirst(substr($method, 9)); | 347 $point = lcfirst(substr($method, 9)); |
348 if (!method_exists($this, 'setItunes' . ucfirst($point)) | 348 if (! method_exists($this, 'setItunes' . ucfirst($point)) |
349 && !method_exists($this, 'addItunes' . ucfirst($point)) | 349 && ! method_exists($this, 'addItunes' . ucfirst($point)) |
350 ) { | 350 ) { |
351 throw new Writer\Exception\BadMethodCallException( | 351 throw new Writer\Exception\BadMethodCallException( |
352 'invalid method: ' . $method | 352 'invalid method: ' . $method |
353 ); | 353 ); |
354 } | 354 } |
355 if (!array_key_exists($point, $this->data) || empty($this->data[$point])) { | 355 if (! array_key_exists($point, $this->data) || empty($this->data[$point])) { |
356 return; | 356 return; |
357 } | 357 } |
358 return $this->data[$point]; | 358 return $this->data[$point]; |
359 } | 359 } |
360 } | 360 } |