comparison vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.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
8 */ 8 */
9 9
10 namespace Zend\Feed\Writer\Extension\ITunes; 10 namespace Zend\Feed\Writer\Extension\ITunes;
11 11
12 use Zend\Feed\Writer; 12 use Zend\Feed\Writer;
13 use Zend\Feed\Writer\Extension;
14 use Zend\Stdlib\StringUtils; 13 use Zend\Stdlib\StringUtils;
15 use Zend\Stdlib\StringWrapper\StringWrapperInterface; 14 use Zend\Stdlib\StringWrapper\StringWrapperInterface;
16 15
17 /** 16 /**
18 */ 17 */
74 * @return Entry 73 * @return Entry
75 * @throws Writer\Exception\InvalidArgumentException 74 * @throws Writer\Exception\InvalidArgumentException
76 */ 75 */
77 public function setItunesBlock($value) 76 public function setItunesBlock($value)
78 { 77 {
79 if (!ctype_alpha($value) && strlen($value) > 0) { 78 if (! ctype_alpha($value) && strlen($value) > 0) {
80 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only' 79 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
81 . ' contain alphabetic characters'); 80 . ' contain alphabetic characters');
82 } 81 }
83 82
84 if ($this->stringWrapper->strlen($value) > 255) { 83 if ($this->stringWrapper->strlen($value) > 255) {
113 { 112 {
114 if ($this->stringWrapper->strlen($value) > 255) { 113 if ($this->stringWrapper->strlen($value) > 255) {
115 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only' 114 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
116 . ' contain a maximum of 255 characters each'); 115 . ' contain a maximum of 255 characters each');
117 } 116 }
118 if (!isset($this->data['authors'])) { 117 if (! isset($this->data['authors'])) {
119 $this->data['authors'] = []; 118 $this->data['authors'] = [];
120 } 119 }
121 $this->data['authors'][] = $value; 120 $this->data['authors'][] = $value;
122 return $this; 121 return $this;
123 } 122 }
130 * @throws Writer\Exception\InvalidArgumentException 129 * @throws Writer\Exception\InvalidArgumentException
131 */ 130 */
132 public function setItunesDuration($value) 131 public function setItunesDuration($value)
133 { 132 {
134 $value = (string) $value; 133 $value = (string) $value;
135 if (!ctype_digit($value) 134 if (! ctype_digit($value)
136 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value) 135 && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
137 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value) 136 && ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
138 ) { 137 ) {
139 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only' 138 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
140 . ' be of a specified [[HH:]MM:]SS format'); 139 . ' be of a specified [[HH:]MM:]SS format');
141 } 140 }
142 $this->data['duration'] = $value; 141 $this->data['duration'] = $value;
150 * @return Entry 149 * @return Entry
151 * @throws Writer\Exception\InvalidArgumentException 150 * @throws Writer\Exception\InvalidArgumentException
152 */ 151 */
153 public function setItunesExplicit($value) 152 public function setItunesExplicit($value)
154 { 153 {
155 if (!in_array($value, ['yes', 'no', 'clean'])) { 154 if (! in_array($value, ['yes', 'no', 'clean'])) {
156 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only' 155 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
157 . ' be one of "yes", "no" or "clean"'); 156 . ' be one of "yes", "no" or "clean"');
158 } 157 }
159 $this->data['explicit'] = $value; 158 $this->data['explicit'] = $value;
160 return $this; 159 return $this;
227 * @return mixed 226 * @return mixed
228 */ 227 */
229 public function __call($method, array $params) 228 public function __call($method, array $params)
230 { 229 {
231 $point = lcfirst(substr($method, 9)); 230 $point = lcfirst(substr($method, 9));
232 if (!method_exists($this, 'setItunes' . ucfirst($point)) 231 if (! method_exists($this, 'setItunes' . ucfirst($point))
233 && !method_exists($this, 'addItunes' . ucfirst($point)) 232 && ! method_exists($this, 'addItunes' . ucfirst($point))
234 ) { 233 ) {
235 throw new Writer\Exception\BadMethodCallException( 234 throw new Writer\Exception\BadMethodCallException(
236 'invalid method: ' . $method 235 'invalid method: ' . $method
237 ); 236 );
238 } 237 }
239 if (!array_key_exists($point, $this->data) 238 if (! array_key_exists($point, $this->data)
240 || empty($this->data[$point]) 239 || empty($this->data[$point])
241 ) { 240 ) {
242 return; 241 return;
243 } 242 }
244 return $this->data[$point]; 243 return $this->data[$point];