@@ -252,7 +252,7 @@ |
||
| 252 | 252 | * |
| 253 | 253 | * @param array $request Request data (same form as {@see request_multiple}). |
| 254 | 254 | * @param boolean $merge_options Should we merge options as well?. |
| 255 | - * @return array Request data |
|
| 255 | + * @return string Request data |
|
| 256 | 256 | */ |
| 257 | 257 | protected function merge_request( $request, $merge_options = true ) { |
| 258 | 258 | if ( null !== $this->url ) { |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | * @param array $data Default data for requests. |
| 66 | 66 | * @param array $options Default options for requests. |
| 67 | 67 | */ |
| 68 | - public function __construct( $url = null, $headers = array(), $data = array(), $options = array() ) { |
|
| 68 | + public function __construct($url = null, $headers = array(), $data = array(), $options = array()) { |
|
| 69 | 69 | $this->url = $url; |
| 70 | 70 | $this->headers = $headers; |
| 71 | 71 | $this->data = $data; |
| 72 | 72 | $this->options = $options; |
| 73 | 73 | |
| 74 | - if ( empty( $this->options['cookies'] ) ) { |
|
| 74 | + if (empty($this->options['cookies'])) { |
|
| 75 | 75 | $this->options['cookies'] = new Requests_Cookie_Jar(); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | * @param string $key Property key. |
| 83 | 83 | * @return mixed|null Property value, null if none found |
| 84 | 84 | */ |
| 85 | - public function __get( $key ) { |
|
| 86 | - if ( isset( $this->options[ $key ] ) ) { |
|
| 87 | - return $this->options[ $key ]; |
|
| 85 | + public function __get($key) { |
|
| 86 | + if (isset($this->options[$key])) { |
|
| 87 | + return $this->options[$key]; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return null; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param string $key Property key. |
| 97 | 97 | * @param mixed $value Property value. |
| 98 | 98 | */ |
| 99 | - public function __set( $key, $value ) { |
|
| 100 | - $this->options[ $key ] = $value; |
|
| 99 | + public function __set($key, $value) { |
|
| 100 | + $this->options[$key] = $value; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param string $key Property key. |
| 107 | 107 | */ |
| 108 | - public function __isset( $key ) { |
|
| 109 | - return isset( $this->options[ $key ] ); |
|
| 108 | + public function __isset($key) { |
|
| 109 | + return isset($this->options[$key]); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param string $key Property key. |
| 116 | 116 | */ |
| 117 | - public function __unset( $key ) { |
|
| 118 | - if ( isset( $this->options[ $key ] ) ) { |
|
| 119 | - unset( $this->options[ $key ] ); |
|
| 117 | + public function __unset($key) { |
|
| 118 | + if (isset($this->options[$key])) { |
|
| 119 | + unset($this->options[$key]); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * @param array $options Options for the request (see {@see Requests::request}). |
| 130 | 130 | * @return Requests_Response |
| 131 | 131 | */ |
| 132 | - public function get( $url, $headers = array(), $options = array() ) { |
|
| 133 | - return $this->request( $url, $headers, null, Requests::GET, $options ); |
|
| 132 | + public function get($url, $headers = array(), $options = array()) { |
|
| 133 | + return $this->request($url, $headers, null, Requests::GET, $options); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * @param array $options Options for the request (see {@see Requests::request}). |
| 142 | 142 | * @return Requests_Response |
| 143 | 143 | */ |
| 144 | - public function head( $url, $headers = array(), $options = array() ) { |
|
| 145 | - return $this->request( $url, $headers, null, Requests::HEAD, $options ); |
|
| 144 | + public function head($url, $headers = array(), $options = array()) { |
|
| 145 | + return $this->request($url, $headers, null, Requests::HEAD, $options); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | * @param array $options Options for the request (see {@see Requests::request}). |
| 154 | 154 | * @return Requests_Response |
| 155 | 155 | */ |
| 156 | - public function delete( $url, $headers = array(), $options = array() ) { |
|
| 157 | - return $this->request( $url, $headers, null, Requests::DELETE, $options ); |
|
| 156 | + public function delete($url, $headers = array(), $options = array()) { |
|
| 157 | + return $this->request($url, $headers, null, Requests::DELETE, $options); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * @param array $options Options for the request (see {@see Requests::request}). |
| 168 | 168 | * @return Requests_Response |
| 169 | 169 | */ |
| 170 | - public function post( $url, $headers = array(), $data = array(), $options = array() ) { |
|
| 171 | - return $this->request( $url, $headers, $data, Requests::POST, $options ); |
|
| 170 | + public function post($url, $headers = array(), $data = array(), $options = array()) { |
|
| 171 | + return $this->request($url, $headers, $data, Requests::POST, $options); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | * @param array $options Options for the request (see {@see Requests::request}). |
| 181 | 181 | * @return Requests_Response |
| 182 | 182 | */ |
| 183 | - public function put( $url, $headers = array(), $data = array(), $options = array() ) { |
|
| 184 | - return $this->request( $url, $headers, $data, Requests::PUT, $options ); |
|
| 183 | + public function put($url, $headers = array(), $data = array(), $options = array()) { |
|
| 184 | + return $this->request($url, $headers, $data, Requests::PUT, $options); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | * @param array $options Options for the request (see {@see Requests::request}). |
| 199 | 199 | * @return Requests_Response |
| 200 | 200 | */ |
| 201 | - public function patch( $url, $headers, $data = array(), $options = array() ) { |
|
| 202 | - return $this->request( $url, $headers, $data, Requests::PATCH, $options ); |
|
| 201 | + public function patch($url, $headers, $data = array(), $options = array()) { |
|
| 202 | + return $this->request($url, $headers, $data, Requests::PATCH, $options); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | * @param array $options Options for the request (see {@see Requests::request}). |
| 220 | 220 | * @return Requests_Response |
| 221 | 221 | */ |
| 222 | - public function request( $url, $headers = array(), $data = array(), $type = Requests::GET, $options = array() ) { |
|
| 223 | - $request = $this->merge_request( compact( 'url', 'headers', 'data', 'options' ) ); |
|
| 222 | + public function request($url, $headers = array(), $data = array(), $type = Requests::GET, $options = array()) { |
|
| 223 | + $request = $this->merge_request(compact('url', 'headers', 'data', 'options')); |
|
| 224 | 224 | |
| 225 | - return Requests::request( $request['url'], $request['headers'], $request['data'], $type, $request['options'] ); |
|
| 225 | + return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -234,17 +234,17 @@ discard block |
||
| 234 | 234 | * @param array $options Global and default options (see {@see Requests::request}). |
| 235 | 235 | * @return array Responses (either Requests_Response or a Requests_Exception object). |
| 236 | 236 | */ |
| 237 | - public function request_multiple( $requests, $options = array() ) { |
|
| 238 | - foreach ( $requests as $key => $request ) { |
|
| 239 | - $requests[ $key ] = $this->merge_request( $request, false ); |
|
| 237 | + public function request_multiple($requests, $options = array()) { |
|
| 238 | + foreach ($requests as $key => $request) { |
|
| 239 | + $requests[$key] = $this->merge_request($request, false); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - $options = array_merge( $this->options, $options ); |
|
| 242 | + $options = array_merge($this->options, $options); |
|
| 243 | 243 | |
| 244 | 244 | // Disallow forcing the type, as that's a per request setting. |
| 245 | - unset( $options['type'] ); |
|
| 245 | + unset($options['type']); |
|
| 246 | 246 | |
| 247 | - return Requests::request_multiple( $requests, $options ); |
|
| 247 | + return Requests::request_multiple($requests, $options); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -254,30 +254,30 @@ discard block |
||
| 254 | 254 | * @param boolean $merge_options Should we merge options as well?. |
| 255 | 255 | * @return array Request data |
| 256 | 256 | */ |
| 257 | - protected function merge_request( $request, $merge_options = true ) { |
|
| 258 | - if ( null !== $this->url ) { |
|
| 259 | - $request['url'] = Requests_IRI::absolutize( $this->url, $request['url'] ); |
|
| 257 | + protected function merge_request($request, $merge_options = true) { |
|
| 258 | + if (null !== $this->url) { |
|
| 259 | + $request['url'] = Requests_IRI::absolutize($this->url, $request['url']); |
|
| 260 | 260 | $request['url'] = $request['url']->uri; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if ( empty( $request['headers'] ) ) { |
|
| 263 | + if (empty($request['headers'])) { |
|
| 264 | 264 | $request['headers'] = array(); |
| 265 | 265 | } |
| 266 | - $request['headers'] = array_merge( $this->headers, $request['headers'] ); |
|
| 266 | + $request['headers'] = array_merge($this->headers, $request['headers']); |
|
| 267 | 267 | |
| 268 | - if ( empty( $request['data'] ) ) { |
|
| 269 | - if ( is_array( $this->data ) ) { |
|
| 268 | + if (empty($request['data'])) { |
|
| 269 | + if (is_array($this->data)) { |
|
| 270 | 270 | $request['data'] = $this->data; |
| 271 | 271 | } |
| 272 | - } elseif ( is_array( $request['data'] ) && is_array( $this->data ) ) { |
|
| 273 | - $request['data'] = array_merge( $this->data, $request['data'] ); |
|
| 272 | + } elseif (is_array($request['data']) && is_array($this->data)) { |
|
| 273 | + $request['data'] = array_merge($this->data, $request['data']); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( false !== $merge_options ) { |
|
| 277 | - $request['options'] = array_merge( $this->options, $request['options'] ); |
|
| 276 | + if (false !== $merge_options) { |
|
| 277 | + $request['options'] = array_merge($this->options, $request['options']); |
|
| 278 | 278 | |
| 279 | 279 | // Disallow forcing the type, as that's a per request setting. |
| 280 | - unset( $request['options']['type'] ); |
|
| 280 | + unset($request['options']['type']); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | return $request; |
@@ -269,7 +269,8 @@ |
||
| 269 | 269 | if ( is_array( $this->data ) ) { |
| 270 | 270 | $request['data'] = $this->data; |
| 271 | 271 | } |
| 272 | - } elseif ( is_array( $request['data'] ) && is_array( $this->data ) ) { |
|
| 272 | + } |
|
| 273 | + elseif ( is_array( $request['data'] ) && is_array( $this->data ) ) { |
|
| 273 | 274 | $request['data'] = array_merge( $this->data, $request['data'] ); |
| 274 | 275 | } |
| 275 | 276 | |