@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public function getSlug(){ |
|
85 | + public function getSlug() { |
|
86 | 86 | return $this->_slug; |
87 | 87 | } |
88 | 88 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @var string The slug value |
94 | 94 | * @return Zend_Gdata_App_MediaSource Provides a fluent interface |
95 | 95 | */ |
96 | - public function setSlug($value){ |
|
96 | + public function setSlug($value) { |
|
97 | 97 | $this->_slug = $value; |
98 | 98 | return $this; |
99 | 99 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function __get($name) |
112 | 112 | { |
113 | - $method = 'get'.ucfirst($name); |
|
113 | + $method = 'get' . ucfirst($name); |
|
114 | 114 | if (method_exists($this, $method)) { |
115 | 115 | return call_user_func(array(&$this, $method)); |
116 | 116 | } else if (property_exists($this, "_${name}")) { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function __set($name, $val) |
136 | 136 | { |
137 | - $method = 'set'.ucfirst($name); |
|
137 | + $method = 'set' . ucfirst($name); |
|
138 | 138 | if (method_exists($this, $method)) { |
139 | 139 | return call_user_func(array(&$this, $method), $val); |
140 | 140 | } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { |
@@ -107,23 +107,23 @@ |
||
107 | 107 | protected $_updated = null; |
108 | 108 | |
109 | 109 | /** |
110 | - * Indicates the major protocol version that should be used. |
|
111 | - * At present, recognized values are either 1 or 2. However, any integer |
|
112 | - * value >= 1 is considered valid. |
|
113 | - * |
|
114 | - * @see setMajorProtocolVersion() |
|
115 | - * @see getMajorProtocolVersion() |
|
116 | - */ |
|
110 | + * Indicates the major protocol version that should be used. |
|
111 | + * At present, recognized values are either 1 or 2. However, any integer |
|
112 | + * value >= 1 is considered valid. |
|
113 | + * |
|
114 | + * @see setMajorProtocolVersion() |
|
115 | + * @see getMajorProtocolVersion() |
|
116 | + */ |
|
117 | 117 | protected $_majorProtocolVersion = 1; |
118 | 118 | |
119 | 119 | /** |
120 | - * Indicates the minor protocol version that should be used. Can be set |
|
121 | - * to either an integer >= 0, or NULL if no minor version should be sent |
|
122 | - * to the server. |
|
123 | - * |
|
124 | - * @see setMinorProtocolVersion() |
|
125 | - * @see getMinorProtocolVersion() |
|
126 | - */ |
|
120 | + * Indicates the minor protocol version that should be used. Can be set |
|
121 | + * to either an integer >= 0, or NULL if no minor version should be sent |
|
122 | + * to the server. |
|
123 | + * |
|
124 | + * @see setMinorProtocolVersion() |
|
125 | + * @see getMinorProtocolVersion() |
|
126 | + */ |
|
127 | 127 | protected $_minorProtocolVersion = null; |
128 | 128 | |
129 | 129 | /** |
@@ -235,49 +235,49 @@ |
||
235 | 235 | { |
236 | 236 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; |
237 | 237 | switch ($absoluteNodeName) { |
238 | - case $this->lookupNamespace('atom') . ':' . 'author': |
|
239 | - $author = new Zend_Gdata_App_Extension_Author(); |
|
240 | - $author->transferFromDOM($child); |
|
241 | - $this->_author[] = $author; |
|
242 | - break; |
|
243 | - case $this->lookupNamespace('atom') . ':' . 'category': |
|
244 | - $category = new Zend_Gdata_App_Extension_Category(); |
|
245 | - $category->transferFromDOM($child); |
|
246 | - $this->_category[] = $category; |
|
247 | - break; |
|
248 | - case $this->lookupNamespace('atom') . ':' . 'contributor': |
|
249 | - $contributor = new Zend_Gdata_App_Extension_Contributor(); |
|
250 | - $contributor->transferFromDOM($child); |
|
251 | - $this->_contributor[] = $contributor; |
|
252 | - break; |
|
253 | - case $this->lookupNamespace('atom') . ':' . 'id': |
|
254 | - $id = new Zend_Gdata_App_Extension_Id(); |
|
255 | - $id->transferFromDOM($child); |
|
256 | - $this->_id = $id; |
|
257 | - break; |
|
258 | - case $this->lookupNamespace('atom') . ':' . 'link': |
|
259 | - $link = new Zend_Gdata_App_Extension_Link(); |
|
260 | - $link->transferFromDOM($child); |
|
261 | - $this->_link[] = $link; |
|
262 | - break; |
|
263 | - case $this->lookupNamespace('atom') . ':' . 'rights': |
|
264 | - $rights = new Zend_Gdata_App_Extension_Rights(); |
|
265 | - $rights->transferFromDOM($child); |
|
266 | - $this->_rights = $rights; |
|
267 | - break; |
|
268 | - case $this->lookupNamespace('atom') . ':' . 'title': |
|
269 | - $title = new Zend_Gdata_App_Extension_Title(); |
|
270 | - $title->transferFromDOM($child); |
|
271 | - $this->_title = $title; |
|
272 | - break; |
|
273 | - case $this->lookupNamespace('atom') . ':' . 'updated': |
|
274 | - $updated = new Zend_Gdata_App_Extension_Updated(); |
|
275 | - $updated->transferFromDOM($child); |
|
276 | - $this->_updated = $updated; |
|
277 | - break; |
|
278 | - default: |
|
279 | - parent::takeChildFromDOM($child); |
|
280 | - break; |
|
238 | + case $this->lookupNamespace('atom') . ':' . 'author': |
|
239 | + $author = new Zend_Gdata_App_Extension_Author(); |
|
240 | + $author->transferFromDOM($child); |
|
241 | + $this->_author[] = $author; |
|
242 | + break; |
|
243 | + case $this->lookupNamespace('atom') . ':' . 'category': |
|
244 | + $category = new Zend_Gdata_App_Extension_Category(); |
|
245 | + $category->transferFromDOM($child); |
|
246 | + $this->_category[] = $category; |
|
247 | + break; |
|
248 | + case $this->lookupNamespace('atom') . ':' . 'contributor': |
|
249 | + $contributor = new Zend_Gdata_App_Extension_Contributor(); |
|
250 | + $contributor->transferFromDOM($child); |
|
251 | + $this->_contributor[] = $contributor; |
|
252 | + break; |
|
253 | + case $this->lookupNamespace('atom') . ':' . 'id': |
|
254 | + $id = new Zend_Gdata_App_Extension_Id(); |
|
255 | + $id->transferFromDOM($child); |
|
256 | + $this->_id = $id; |
|
257 | + break; |
|
258 | + case $this->lookupNamespace('atom') . ':' . 'link': |
|
259 | + $link = new Zend_Gdata_App_Extension_Link(); |
|
260 | + $link->transferFromDOM($child); |
|
261 | + $this->_link[] = $link; |
|
262 | + break; |
|
263 | + case $this->lookupNamespace('atom') . ':' . 'rights': |
|
264 | + $rights = new Zend_Gdata_App_Extension_Rights(); |
|
265 | + $rights->transferFromDOM($child); |
|
266 | + $this->_rights = $rights; |
|
267 | + break; |
|
268 | + case $this->lookupNamespace('atom') . ':' . 'title': |
|
269 | + $title = new Zend_Gdata_App_Extension_Title(); |
|
270 | + $title->transferFromDOM($child); |
|
271 | + $this->_title = $title; |
|
272 | + break; |
|
273 | + case $this->lookupNamespace('atom') . ':' . 'updated': |
|
274 | + $updated = new Zend_Gdata_App_Extension_Updated(); |
|
275 | + $updated->transferFromDOM($child); |
|
276 | + $this->_updated = $updated; |
|
277 | + break; |
|
278 | + default: |
|
279 | + parent::takeChildFromDOM($child); |
|
280 | + break; |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | return (array_key_exists($key, $this->_entry)); |
271 | 271 | } |
272 | 272 | |
273 | - /** |
|
273 | + /** |
|
274 | 274 | * Retrieve the next set of results from this feed. |
275 | 275 | * |
276 | 276 | * @throws Zend_Gdata_App_Exception |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | return $service->getFeed($nextLinkHref, get_class($this)); |
292 | 292 | } |
293 | 293 | |
294 | - /** |
|
294 | + /** |
|
295 | 295 | * Retrieve the previous set of results from this feed. |
296 | 296 | * |
297 | 297 | * @throws Zend_Gdata_App_Exception |
@@ -111,16 +111,16 @@ |
||
111 | 111 | { |
112 | 112 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; |
113 | 113 | switch ($absoluteNodeName) { |
114 | - case $this->lookupNamespace('atom') . ':' . 'entry': |
|
115 | - $newEntry = new $this->_entryClassName($child); |
|
116 | - $newEntry->setHttpClient($this->getHttpClient()); |
|
117 | - $newEntry->setMajorProtocolVersion($this->getMajorProtocolVersion()); |
|
118 | - $newEntry->setMinorProtocolVersion($this->getMinorProtocolVersion()); |
|
119 | - $this->_entry[] = $newEntry; |
|
120 | - break; |
|
121 | - default: |
|
122 | - parent::takeChildFromDOM($child); |
|
123 | - break; |
|
114 | + case $this->lookupNamespace('atom') . ':' . 'entry': |
|
115 | + $newEntry = new $this->_entryClassName($child); |
|
116 | + $newEntry->setHttpClient($this->getHttpClient()); |
|
117 | + $newEntry->setMajorProtocolVersion($this->getMajorProtocolVersion()); |
|
118 | + $newEntry->setMinorProtocolVersion($this->getMinorProtocolVersion()); |
|
119 | + $this->_entry[] = $newEntry; |
|
120 | + break; |
|
121 | + default: |
|
122 | + parent::takeChildFromDOM($child); |
|
123 | + break; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 |
@@ -152,39 +152,39 @@ |
||
152 | 152 | { |
153 | 153 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; |
154 | 154 | switch ($absoluteNodeName) { |
155 | - case $this->lookupNamespace('atom') . ':' . 'content': |
|
156 | - $content = new Zend_Gdata_App_Extension_Content(); |
|
157 | - $content->transferFromDOM($child); |
|
158 | - $this->_content = $content; |
|
159 | - break; |
|
160 | - case $this->lookupNamespace('atom') . ':' . 'published': |
|
161 | - $published = new Zend_Gdata_App_Extension_Published(); |
|
162 | - $published->transferFromDOM($child); |
|
163 | - $this->_published = $published; |
|
164 | - break; |
|
165 | - case $this->lookupNamespace('atom') . ':' . 'source': |
|
166 | - $source = new Zend_Gdata_App_Extension_Source(); |
|
167 | - $source->transferFromDOM($child); |
|
168 | - $this->_source = $source; |
|
169 | - break; |
|
170 | - case $this->lookupNamespace('atom') . ':' . 'summary': |
|
171 | - $summary = new Zend_Gdata_App_Extension_Summary(); |
|
172 | - $summary->transferFromDOM($child); |
|
173 | - $this->_summary = $summary; |
|
174 | - break; |
|
175 | - case $this->lookupNamespace('app') . ':' . 'control': |
|
176 | - $control = new Zend_Gdata_App_Extension_Control(); |
|
177 | - $control->transferFromDOM($child); |
|
178 | - $this->_control = $control; |
|
179 | - break; |
|
180 | - case $this->lookupNamespace('app') . ':' . 'edited': |
|
181 | - $edited = new Zend_Gdata_App_Extension_Edited(); |
|
182 | - $edited->transferFromDOM($child); |
|
183 | - $this->_edited = $edited; |
|
184 | - break; |
|
185 | - default: |
|
186 | - parent::takeChildFromDOM($child); |
|
187 | - break; |
|
155 | + case $this->lookupNamespace('atom') . ':' . 'content': |
|
156 | + $content = new Zend_Gdata_App_Extension_Content(); |
|
157 | + $content->transferFromDOM($child); |
|
158 | + $this->_content = $content; |
|
159 | + break; |
|
160 | + case $this->lookupNamespace('atom') . ':' . 'published': |
|
161 | + $published = new Zend_Gdata_App_Extension_Published(); |
|
162 | + $published->transferFromDOM($child); |
|
163 | + $this->_published = $published; |
|
164 | + break; |
|
165 | + case $this->lookupNamespace('atom') . ':' . 'source': |
|
166 | + $source = new Zend_Gdata_App_Extension_Source(); |
|
167 | + $source->transferFromDOM($child); |
|
168 | + $this->_source = $source; |
|
169 | + break; |
|
170 | + case $this->lookupNamespace('atom') . ':' . 'summary': |
|
171 | + $summary = new Zend_Gdata_App_Extension_Summary(); |
|
172 | + $summary->transferFromDOM($child); |
|
173 | + $this->_summary = $summary; |
|
174 | + break; |
|
175 | + case $this->lookupNamespace('app') . ':' . 'control': |
|
176 | + $control = new Zend_Gdata_App_Extension_Control(); |
|
177 | + $control->transferFromDOM($child); |
|
178 | + $this->_control = $control; |
|
179 | + break; |
|
180 | + case $this->lookupNamespace('app') . ':' . 'edited': |
|
181 | + $edited = new Zend_Gdata_App_Extension_Edited(); |
|
182 | + $edited->transferFromDOM($child); |
|
183 | + $this->_edited = $edited; |
|
184 | + break; |
|
185 | + default: |
|
186 | + parent::takeChildFromDOM($child); |
|
187 | + break; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 |
@@ -265,8 +265,9 @@ |
||
265 | 265 | try { |
266 | 266 | $result = $this->service->importUrl($uri, $className, $extraHeaders); |
267 | 267 | } catch (Zend_Gdata_App_HttpException $e) { |
268 | - if ($e->getResponse()->getStatus() != '304') |
|
269 | - throw $e; |
|
268 | + if ($e->getResponse()->getStatus() != '304') { |
|
269 | + throw $e; |
|
270 | + } |
|
270 | 271 | } |
271 | 272 | |
272 | 273 | return $result; |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @var string |
127 | 127 | */ |
128 | - const IN_REPLY_TO_SCHEME = |
|
129 | - 'http://gdata.youtube.com/schemas/2007#in-reply-to'; |
|
128 | + const IN_REPLY_TO_SCHEME = |
|
129 | + 'http://gdata.youtube.com/schemas/2007#in-reply-to'; |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * The URI of the inbox feed for the currently authenticated user. |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | { |
593 | 593 | if ($user !== null) { |
594 | 594 | $uri = self::USER_URI . '/' . $user . '/' . |
595 | - self::UPLOADS_URI_SUFFIX; |
|
595 | + self::UPLOADS_URI_SUFFIX; |
|
596 | 596 | } else if ($location instanceof Zend_Gdata_Query) { |
597 | 597 | $uri = $location->getQueryUrl($this->getMajorProtocolVersion()); |
598 | 598 | } else { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | { |
614 | 614 | if ($user !== null) { |
615 | 615 | $uri = self::USER_URI . '/' . $user . '/' . |
616 | - self::FAVORITES_URI_SUFFIX; |
|
616 | + self::FAVORITES_URI_SUFFIX; |
|
617 | 617 | } else if ($location instanceof Zend_Gdata_Query) { |
618 | 618 | $uri = $location->getQueryUrl($this->getMajorProtocolVersion()); |
619 | 619 | } else { |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @param Zend_Gdata_YouTube_CommentEntry $commentEntry The comment entry |
850 | 850 | * to reply to |
851 | 851 | * @param string $commentText The text of the |
852 | - * comment to post |
|
852 | + * comment to post |
|
853 | 853 | * @return Zend_Gdata_YouTube_CommentEntry the posted comment |
854 | 854 | */ |
855 | 855 | public function replyToCommentEntry($commentEntry, $commentText) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | if ($developerKey != null) { |
242 | - $client->setHeaders('X-GData-Key', 'key='. $developerKey); |
|
242 | + $client->setHeaders('X-GData-Key', 'key=' . $developerKey); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return parent::setHttpClient($client, $applicationId); |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * @return array An array containing a token and URL |
700 | 700 | */ |
701 | 701 | public function getFormUploadToken($videoEntry, |
702 | - $url='https://gdata.youtube.com/action/GetUploadToken') |
|
702 | + $url = 'https://gdata.youtube.com/action/GetUploadToken') |
|
703 | 703 | { |
704 | 704 | if ($url != null && is_string($url)) { |
705 | 705 | // $response is a Zend_Http_response object |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | require_once 'Zend/Gdata/App/InvalidArgumentException.php'; |
739 | 739 | throw new Zend_Gdata_App_InvalidArgumentException( |
740 | 740 | 'Activity feed can only retrieve for activity for up to ' . |
741 | - self::ACTIVITY_FEED_MAX_USERS . ' users per request'); |
|
741 | + self::ACTIVITY_FEED_MAX_USERS . ' users per request'); |
|
742 | 742 | } |
743 | 743 | $uri = self::ACTIVITY_FEED_URI . '?author=' . $username; |
744 | 744 | } |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | $inReplyToLinkHref = self::VIDEO_URI . '/' . $commentIdArray[3] . |
864 | 864 | '/comments/' . $commentIdArray[5]; |
865 | 865 | $inReplyToLink = $this->newLink($inReplyToLinkHref, |
866 | - self::IN_REPLY_TO_SCHEME, $type="application/atom+xml"); |
|
866 | + self::IN_REPLY_TO_SCHEME, $type = "application/atom+xml"); |
|
867 | 867 | $links = $newComment->getLink(); |
868 | 868 | $links[] = $inReplyToLink; |
869 | 869 | $newComment->setLink($links); |
@@ -70,7 +70,7 @@ |
||
70 | 70 | public static $namespaces = array( |
71 | 71 | array('analytics', 'http://schemas.google.com/analytics/2009', 1, 0), |
72 | 72 | array('ga', 'http://schemas.google.com/ga/2009', 1, 0) |
73 | - ); |
|
73 | + ); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Create Gdata object |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * Retrieve the array of all configuration options |
|
129 | - * |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function getConfig() |
|
133 | - { |
|
134 | - return $this->config; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Set the stream context for the TCP connection to the server |
|
128 | + * Retrieve the array of all configuration options |
|
139 | 129 | * |
140 | - * Can accept either a pre-existing stream context resource, or an array |
|
141 | - * of stream options, similar to the options array passed to the |
|
142 | - * stream_context_create() PHP function. In such case a new stream context |
|
143 | - * will be created using the passed options. |
|
144 | - * |
|
145 | - * @since Zend Framework 1.9 |
|
146 | - * |
|
147 | - * @param mixed $context Stream context or array of context options |
|
148 | - * @return Zend_Http_Client_Adapter_Socket |
|
130 | + * @return array |
|
149 | 131 | */ |
132 | + public function getConfig() |
|
133 | + { |
|
134 | + return $this->config; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Set the stream context for the TCP connection to the server |
|
139 | + * |
|
140 | + * Can accept either a pre-existing stream context resource, or an array |
|
141 | + * of stream options, similar to the options array passed to the |
|
142 | + * stream_context_create() PHP function. In such case a new stream context |
|
143 | + * will be created using the passed options. |
|
144 | + * |
|
145 | + * @since Zend Framework 1.9 |
|
146 | + * |
|
147 | + * @param mixed $context Stream context or array of context options |
|
148 | + * @return Zend_Http_Client_Adapter_Socket |
|
149 | + */ |
|
150 | 150 | public function setStreamContext($context) |
151 | 151 | { |
152 | 152 | if (is_resource($context) && get_resource_type($context) == 'stream-context') { |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | if ($this->config['persistent']) $flags |= STREAM_CLIENT_PERSISTENT; |
224 | 224 | |
225 | 225 | $this->socket = @stream_socket_client($host . ':' . $port, |
226 | - $errno, |
|
227 | - $errstr, |
|
228 | - (int) $this->config['timeout'], |
|
229 | - $flags, |
|
230 | - $context); |
|
226 | + $errno, |
|
227 | + $errstr, |
|
228 | + (int) $this->config['timeout'], |
|
229 | + $flags, |
|
230 | + $context); |
|
231 | 231 | |
232 | 232 | if (! $this->socket) { |
233 | 233 | $this->close(); |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | |
383 | 383 | if($this->out_stream) { |
384 | 384 | if(stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
385 | - $this->_checkSocketReadTimeout(); |
|
386 | - break; |
|
387 | - } |
|
385 | + $this->_checkSocketReadTimeout(); |
|
386 | + break; |
|
387 | + } |
|
388 | 388 | } else { |
389 | 389 | $line = @fread($this->socket, $read_to - $current_pos); |
390 | 390 | if ($line === false || strlen($line) === 0) { |
@@ -429,15 +429,15 @@ discard block |
||
429 | 429 | $chunk = ''; |
430 | 430 | |
431 | 431 | for ($read_to = $current_pos + $contentLength; |
432 | - $read_to > $current_pos; |
|
433 | - $current_pos = ftell($this->socket)) { |
|
434 | - |
|
435 | - if($this->out_stream) { |
|
436 | - if(@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
437 | - $this->_checkSocketReadTimeout(); |
|
438 | - break; |
|
439 | - } |
|
440 | - } else { |
|
432 | + $read_to > $current_pos; |
|
433 | + $current_pos = ftell($this->socket)) { |
|
434 | + |
|
435 | + if($this->out_stream) { |
|
436 | + if(@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
437 | + $this->_checkSocketReadTimeout(); |
|
438 | + break; |
|
439 | + } |
|
440 | + } else { |
|
441 | 441 | $chunk = @fread($this->socket, $read_to - $current_pos); |
442 | 442 | if ($chunk === false || strlen($chunk) === 0) { |
443 | 443 | $this->_checkSocketReadTimeout(); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | do { |
458 | 458 | if($this->out_stream) { |
459 | 459 | if(@stream_copy_to_stream($this->socket, $this->out_stream) == 0) { |
460 | - $this->_checkSocketReadTimeout(); |
|
461 | - break; |
|
462 | - } |
|
460 | + $this->_checkSocketReadTimeout(); |
|
461 | + break; |
|
462 | + } |
|
463 | 463 | } else { |
464 | 464 | $buff = @fread($this->socket, 8192); |
465 | 465 | if ($buff === false || strlen($buff) === 0) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($config instanceof Zend_Config) { |
113 | 113 | $config = $config->toArray(); |
114 | 114 | |
115 | - } elseif (! is_array($config)) { |
|
115 | + } elseif (!is_array($config)) { |
|
116 | 116 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
117 | 117 | throw new Zend_Http_Client_Adapter_Exception( |
118 | 118 | 'Array or Zend_Config object expected, got ' . gettype($config) |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function getStreamContext() |
177 | 177 | { |
178 | - if (! $this->_context) { |
|
178 | + if (!$this->_context) { |
|
179 | 179 | $this->_context = stream_context_create(); |
180 | 180 | } |
181 | 181 | |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // Now, if we are not connected, connect |
203 | - if (! is_resource($this->socket) || ! $this->config['keepalive']) { |
|
203 | + if (!is_resource($this->socket) || !$this->config['keepalive']) { |
|
204 | 204 | $context = $this->getStreamContext(); |
205 | 205 | if ($secure || $this->config['sslusecontext']) { |
206 | 206 | if ($this->config['sslcert'] !== null) { |
207 | - if (! stream_context_set_option($context, 'ssl', 'local_cert', |
|
207 | + if (!stream_context_set_option($context, 'ssl', 'local_cert', |
|
208 | 208 | $this->config['sslcert'])) { |
209 | 209 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
210 | 210 | throw new Zend_Http_Client_Adapter_Exception('Unable to set sslcert option'); |
211 | 211 | } |
212 | 212 | } |
213 | 213 | if ($this->config['sslpassphrase'] !== null) { |
214 | - if (! stream_context_set_option($context, 'ssl', 'passphrase', |
|
214 | + if (!stream_context_set_option($context, 'ssl', 'passphrase', |
|
215 | 215 | $this->config['sslpassphrase'])) { |
216 | 216 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
217 | 217 | throw new Zend_Http_Client_Adapter_Exception('Unable to set sslpassphrase option'); |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | $this->socket = @stream_socket_client($host . ':' . $port, |
226 | 226 | $errno, |
227 | 227 | $errstr, |
228 | - (int) $this->config['timeout'], |
|
228 | + (int)$this->config['timeout'], |
|
229 | 229 | $flags, |
230 | 230 | $context); |
231 | 231 | |
232 | - if (! $this->socket) { |
|
232 | + if (!$this->socket) { |
|
233 | 233 | $this->close(); |
234 | 234 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
235 | 235 | throw new Zend_Http_Client_Adapter_Exception( |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | // Set the stream timeout |
240 | - if (! stream_set_timeout($this->socket, (int) $this->config['timeout'])) { |
|
240 | + if (!stream_set_timeout($this->socket, (int)$this->config['timeout'])) { |
|
241 | 241 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
242 | 242 | throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout'); |
243 | 243 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') |
261 | 261 | { |
262 | 262 | // Make sure we're properly connected |
263 | - if (! $this->socket) { |
|
263 | + if (!$this->socket) { |
|
264 | 264 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
265 | 265 | throw new Zend_Http_Client_Adapter_Exception('Trying to write but we are not connected'); |
266 | 266 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $request .= "$v\r\n"; |
285 | 285 | } |
286 | 286 | |
287 | - if(is_resource($body)) { |
|
287 | + if (is_resource($body)) { |
|
288 | 288 | $request .= "\r\n"; |
289 | 289 | } else { |
290 | 290 | // Add the request body |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | // Send the request |
295 | - if (! @fwrite($this->socket, $request)) { |
|
295 | + if (!@fwrite($this->socket, $request)) { |
|
296 | 296 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
297 | 297 | throw new Zend_Http_Client_Adapter_Exception('Error writing request to server'); |
298 | 298 | } |
299 | 299 | |
300 | - if(is_resource($body)) { |
|
301 | - if(stream_copy_to_stream($body, $this->socket) == 0) { |
|
300 | + if (is_resource($body)) { |
|
301 | + if (stream_copy_to_stream($body, $this->socket) == 0) { |
|
302 | 302 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
303 | 303 | throw new Zend_Http_Client_Adapter_Exception('Error writing request to server'); |
304 | 304 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | |
364 | 364 | // Figure out the next chunk size |
365 | 365 | $chunksize = trim($line); |
366 | - if (! ctype_xdigit($chunksize)) { |
|
366 | + if (!ctype_xdigit($chunksize)) { |
|
367 | 367 | $this->close(); |
368 | 368 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
369 | 369 | throw new Zend_Http_Client_Adapter_Exception('Invalid chunk size "' . |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | $current_pos = ftell($this->socket); |
381 | 381 | if ($current_pos >= $read_to) break; |
382 | 382 | |
383 | - if($this->out_stream) { |
|
384 | - if(stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
383 | + if ($this->out_stream) { |
|
384 | + if (stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
385 | 385 | $this->_checkSocketReadTimeout(); |
386 | 386 | break; |
387 | 387 | } |
@@ -393,12 +393,12 @@ discard block |
||
393 | 393 | } |
394 | 394 | $chunk .= $line; |
395 | 395 | } |
396 | - } while (! feof($this->socket)); |
|
396 | + } while (!feof($this->socket)); |
|
397 | 397 | |
398 | 398 | $chunk .= @fgets($this->socket); |
399 | 399 | $this->_checkSocketReadTimeout(); |
400 | 400 | |
401 | - if(!$this->out_stream) { |
|
401 | + if (!$this->out_stream) { |
|
402 | 402 | $response .= $chunk; |
403 | 403 | } |
404 | 404 | } while ($chunksize > 0); |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | $read_to > $current_pos; |
433 | 433 | $current_pos = ftell($this->socket)) { |
434 | 434 | |
435 | - if($this->out_stream) { |
|
436 | - if(@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
435 | + if ($this->out_stream) { |
|
436 | + if (@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
|
437 | 437 | $this->_checkSocketReadTimeout(); |
438 | 438 | break; |
439 | 439 | } |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | } else { |
456 | 456 | |
457 | 457 | do { |
458 | - if($this->out_stream) { |
|
459 | - if(@stream_copy_to_stream($this->socket, $this->out_stream) == 0) { |
|
458 | + if ($this->out_stream) { |
|
459 | + if (@stream_copy_to_stream($this->socket, $this->out_stream) == 0) { |
|
460 | 460 | $this->_checkSocketReadTimeout(); |
461 | 461 | break; |
462 | 462 | } |
463 | - } else { |
|
463 | + } else { |
|
464 | 464 | $buff = @fread($this->socket, 8192); |
465 | 465 | if ($buff === false || strlen($buff) === 0) { |
466 | 466 | $this->_checkSocketReadTimeout(); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | */ |
537 | 537 | public function __destruct() |
538 | 538 | { |
539 | - if (! $this->config['persistent']) { |
|
539 | + if (!$this->config['persistent']) { |
|
540 | 540 | if ($this->socket) $this->close(); |
541 | 541 | } |
542 | 542 | } |
@@ -196,7 +196,9 @@ discard block |
||
196 | 196 | |
197 | 197 | // If we are connected to the wrong host, disconnect first |
198 | 198 | if (($this->connected_to[0] != $host || $this->connected_to[1] != $port)) { |
199 | - if (is_resource($this->socket)) $this->close(); |
|
199 | + if (is_resource($this->socket)) { |
|
200 | + $this->close(); |
|
201 | + } |
|
200 | 202 | } |
201 | 203 | |
202 | 204 | // Now, if we are not connected, connect |
@@ -220,7 +222,9 @@ discard block |
||
220 | 222 | } |
221 | 223 | |
222 | 224 | $flags = STREAM_CLIENT_CONNECT; |
223 | - if ($this->config['persistent']) $flags |= STREAM_CLIENT_PERSISTENT; |
|
225 | + if ($this->config['persistent']) { |
|
226 | + $flags |= STREAM_CLIENT_PERSISTENT; |
|
227 | + } |
|
224 | 228 | |
225 | 229 | $this->socket = @stream_socket_client($host . ':' . $port, |
226 | 230 | $errno, |
@@ -277,10 +281,14 @@ discard block |
||
277 | 281 | |
278 | 282 | // Build request headers |
279 | 283 | $path = $uri->getPath(); |
280 | - if ($uri->getQuery()) $path .= '?' . $uri->getQuery(); |
|
284 | + if ($uri->getQuery()) { |
|
285 | + $path .= '?' . $uri->getQuery(); |
|
286 | + } |
|
281 | 287 | $request = "{$method} {$path} HTTP/{$http_ver}\r\n"; |
282 | 288 | foreach ($headers as $k => $v) { |
283 | - if (is_string($k)) $v = ucfirst($k) . ": $v"; |
|
289 | + if (is_string($k)) { |
|
290 | + $v = ucfirst($k) . ": $v"; |
|
291 | + } |
|
284 | 292 | $request .= "$v\r\n"; |
285 | 293 | } |
286 | 294 | |
@@ -322,7 +330,9 @@ discard block |
||
322 | 330 | $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false); |
323 | 331 | if ($gotStatus) { |
324 | 332 | $response .= $line; |
325 | - if (rtrim($line) === '') break; |
|
333 | + if (rtrim($line) === '') { |
|
334 | + break; |
|
335 | + } |
|
326 | 336 | } |
327 | 337 | } |
328 | 338 | |
@@ -331,7 +341,9 @@ discard block |
||
331 | 341 | $statusCode = Zend_Http_Response::extractCode($response); |
332 | 342 | |
333 | 343 | // Handle 100 and 101 responses internally by restarting the read again |
334 | - if ($statusCode == 100 || $statusCode == 101) return $this->read(); |
|
344 | + if ($statusCode == 100 || $statusCode == 101) { |
|
345 | + return $this->read(); |
|
346 | + } |
|
335 | 347 | |
336 | 348 | // Check headers to see what kind of connection / transfer encoding we have |
337 | 349 | $headers = Zend_Http_Response::extractHeaders($response); |
@@ -378,7 +390,9 @@ discard block |
||
378 | 390 | |
379 | 391 | do { |
380 | 392 | $current_pos = ftell($this->socket); |
381 | - if ($current_pos >= $read_to) break; |
|
393 | + if ($current_pos >= $read_to) { |
|
394 | + break; |
|
395 | + } |
|
382 | 396 | |
383 | 397 | if($this->out_stream) { |
384 | 398 | if(stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) { |
@@ -448,7 +462,9 @@ discard block |
||
448 | 462 | } |
449 | 463 | |
450 | 464 | // Break if the connection ended prematurely |
451 | - if (feof($this->socket)) break; |
|
465 | + if (feof($this->socket)) { |
|
466 | + break; |
|
467 | + } |
|
452 | 468 | } |
453 | 469 | |
454 | 470 | // Fallback: just read the response until EOF |
@@ -460,7 +476,7 @@ discard block |
||
460 | 476 | $this->_checkSocketReadTimeout(); |
461 | 477 | break; |
462 | 478 | } |
463 | - } else { |
|
479 | + } else { |
|
464 | 480 | $buff = @fread($this->socket, 8192); |
465 | 481 | if ($buff === false || strlen($buff) === 0) { |
466 | 482 | $this->_checkSocketReadTimeout(); |
@@ -489,7 +505,9 @@ discard block |
||
489 | 505 | */ |
490 | 506 | public function close() |
491 | 507 | { |
492 | - if (is_resource($this->socket)) @fclose($this->socket); |
|
508 | + if (is_resource($this->socket)) { |
|
509 | + @fclose($this->socket); |
|
510 | + } |
|
493 | 511 | $this->socket = null; |
494 | 512 | $this->connected_to = array(null, null); |
495 | 513 | } |
@@ -537,7 +555,9 @@ discard block |
||
537 | 555 | public function __destruct() |
538 | 556 | { |
539 | 557 | if (! $this->config['persistent']) { |
540 | - if ($this->socket) $this->close(); |
|
558 | + if ($this->socket) { |
|
559 | + $this->close(); |
|
560 | + } |
|
541 | 561 | } |
542 | 562 | } |
543 | 563 | } |
@@ -165,14 +165,14 @@ |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
168 | - * Retrieve the array of all configuration options |
|
169 | - * |
|
170 | - * @return array |
|
171 | - */ |
|
172 | - public function getConfig() |
|
173 | - { |
|
174 | - return $this->_config; |
|
175 | - } |
|
168 | + * Retrieve the array of all configuration options |
|
169 | + * |
|
170 | + * @return array |
|
171 | + */ |
|
172 | + public function getConfig() |
|
173 | + { |
|
174 | + return $this->_config; |
|
175 | + } |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Direct setter for cURL adapter related options. |
@@ -134,21 +134,21 @@ discard block |
||
134 | 134 | if ($config instanceof Zend_Config) { |
135 | 135 | $config = $config->toArray(); |
136 | 136 | |
137 | - } elseif (! is_array($config)) { |
|
137 | + } elseif (!is_array($config)) { |
|
138 | 138 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
139 | 139 | throw new Zend_Http_Client_Adapter_Exception( |
140 | 140 | 'Array or Zend_Config object expected, got ' . gettype($config) |
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - if(isset($config['proxy_user']) && isset($config['proxy_pass'])) { |
|
145 | - $this->setCurlOption(CURLOPT_PROXYUSERPWD, $config['proxy_user'].":".$config['proxy_pass']); |
|
144 | + if (isset($config['proxy_user']) && isset($config['proxy_pass'])) { |
|
145 | + $this->setCurlOption(CURLOPT_PROXYUSERPWD, $config['proxy_user'] . ":" . $config['proxy_pass']); |
|
146 | 146 | unset($config['proxy_user'], $config['proxy_pass']); |
147 | 147 | } |
148 | 148 | |
149 | 149 | foreach ($config as $k => $v) { |
150 | 150 | $option = strtolower($k); |
151 | - switch($option) { |
|
151 | + switch ($option) { |
|
152 | 152 | case 'proxy_host': |
153 | 153 | $this->setCurlOption(CURLOPT_PROXY, $v); |
154 | 154 | break; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->close(); |
242 | 242 | |
243 | 243 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
244 | - throw new Zend_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port); |
|
244 | + throw new Zend_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if ($secure !== false) { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | case Zend_Http_Client::PUT: |
300 | 300 | // There are two different types of PUT request, either a Raw Data string has been set |
301 | 301 | // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used. |
302 | - if(is_resource($body)) { |
|
302 | + if (is_resource($body)) { |
|
303 | 303 | $this->_config['curloptions'][CURLOPT_INFILE] = $body; |
304 | 304 | } |
305 | 305 | if (isset($this->_config['curloptions'][CURLOPT_INFILE])) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | // from $headers at this point: |
308 | 308 | foreach ($headers AS $k => $header) { |
309 | 309 | if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) { |
310 | - if(is_resource($body)) { |
|
310 | + if (is_resource($body)) { |
|
311 | 311 | $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int)$m[1]; |
312 | 312 | } |
313 | 313 | unset($headers[$k]); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | throw new Zend_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE."); |
320 | 320 | } |
321 | 321 | |
322 | - if(is_resource($body)) { |
|
322 | + if (is_resource($body)) { |
|
323 | 323 | $body = ''; |
324 | 324 | } |
325 | 325 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | throw new Zend_Http_Client_Adapter_Exception("Method currently not supported"); |
362 | 362 | } |
363 | 363 | |
364 | - if(is_resource($body) && $curlMethod != CURLOPT_PUT) { |
|
364 | + if (is_resource($body) && $curlMethod != CURLOPT_PUT) { |
|
365 | 365 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
366 | 366 | throw new Zend_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT"); |
367 | 367 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | curl_setopt($this->_curl, CURLOPT_HTTP_VERSION, $curlHttp); |
374 | 374 | curl_setopt($this->_curl, $curlMethod, $curlValue); |
375 | 375 | |
376 | - if($this->out_stream) { |
|
376 | + if ($this->out_stream) { |
|
377 | 377 | // headers will be read into the response |
378 | 378 | curl_setopt($this->_curl, CURLOPT_HEADER, false); |
379 | 379 | curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader")); |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $response = curl_exec($this->_curl); |
437 | 437 | |
438 | 438 | // if we used streaming, headers are already there |
439 | - if(!is_resource($this->out_stream)) { |
|
439 | + if (!is_resource($this->out_stream)) { |
|
440 | 440 | $this->_response = $response; |
441 | 441 | } |
442 | 442 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | */ |
489 | 489 | public function close() |
490 | 490 | { |
491 | - if(is_resource($this->_curl)) { |
|
491 | + if (is_resource($this->_curl)) { |
|
492 | 492 | curl_close($this->_curl); |
493 | 493 | } |
494 | 494 | $this->_curl = null; |
@@ -244,7 +244,7 @@ |
||
244 | 244 | ) |
245 | 245 | { |
246 | 246 | $request = "CONNECT $host:$port HTTP/$http_ver\r\n" . |
247 | - "Host: " . $this->config['proxy_host'] . "\r\n"; |
|
247 | + "Host: " . $this->config['proxy_host'] . "\r\n"; |
|
248 | 248 | |
249 | 249 | // Process provided headers, including important ones to CONNECT request |
250 | 250 | foreach ($headers as $k => $v) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // Check to see if one already exists |
159 | 159 | $hasProxyAuthHeader = false; |
160 | 160 | foreach ($headers as $k => $v) { |
161 | - if ((string) $k == 'proxy-authorization' |
|
161 | + if ((string)$k == 'proxy-authorization' |
|
162 | 162 | || preg_match("/^proxy-authorization:/i", $v) |
163 | 163 | ) { |
164 | 164 | $hasProxyAuthHeader = true; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $request .= "$v\r\n"; |
203 | 203 | } |
204 | 204 | |
205 | - if(is_resource($body)) { |
|
205 | + if (is_resource($body)) { |
|
206 | 206 | $request .= "\r\n"; |
207 | 207 | } else { |
208 | 208 | // Add the request body |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | ); |
218 | 218 | } |
219 | 219 | |
220 | - if(is_resource($body)) { |
|
221 | - if(stream_copy_to_stream($body, $this->socket) == 0) { |
|
220 | + if (is_resource($body)) { |
|
221 | + if (stream_copy_to_stream($body, $this->socket) == 0) { |
|
222 | 222 | require_once 'Zend/Http/Client/Adapter/Exception.php'; |
223 | 223 | throw new Zend_Http_Client_Adapter_Exception( |
224 | 224 | 'Error writing request to server' |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | // Process provided headers, including important ones to CONNECT request |
250 | 250 | foreach ($headers as $k => $v) { |
251 | - switch (strtolower(substr($v,0,strpos($v,':')))) { |
|
251 | + switch (strtolower(substr($v, 0, strpos($v, ':')))) { |
|
252 | 252 | case 'proxy-authorization': |
253 | 253 | // break intentionally omitted |
254 | 254 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | ); |
305 | 305 | |
306 | 306 | $success = false; |
307 | - foreach($modes as $mode) { |
|
307 | + foreach ($modes as $mode) { |
|
308 | 308 | $success = stream_socket_enable_crypto($this->socket, true, $mode); |
309 | 309 | if ($success) { |
310 | 310 | break; |
@@ -101,7 +101,9 @@ |
||
101 | 101 | |
102 | 102 | // Add all headers to the request string |
103 | 103 | foreach ($headers as $k => $v) { |
104 | - if (is_string($k)) $v = "$k: $v"; |
|
104 | + if (is_string($k)) { |
|
105 | + $v = "$k: $v"; |
|
106 | + } |
|
105 | 107 | $request .= "$v\r\n"; |
106 | 108 | } |
107 | 109 |