@@ -125,6 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * @inheritdoc |
| 128 | + * @param string $name |
|
| 128 | 129 | */ |
| 129 | 130 | public function addHeader($name, $value){ |
| 130 | 131 | $token = $name.": ".$value; |
@@ -158,6 +159,7 @@ discard block |
||
| 158 | 159 | |
| 159 | 160 | /** |
| 160 | 161 | * @inheritdoc |
| 162 | + * @param string $body |
|
| 161 | 163 | */ |
| 162 | 164 | public function setBody($body){ |
| 163 | 165 | $this->body = $body; |
@@ -226,10 +226,10 @@ |
||
| 226 | 226 | */ |
| 227 | 227 | protected function configureType(){ |
| 228 | 228 | switch ($this->type) { |
| 229 | - case 'POST': |
|
| 229 | + case 'POST': |
|
| 230 | 230 | $this->setOption(CURLOPT_POST, TRUE); |
| 231 | 231 | break; |
| 232 | - case 'DELETE': |
|
| 232 | + case 'DELETE': |
|
| 233 | 233 | case 'PUT': |
| 234 | 234 | $this->setOption(CURLOPT_CUSTOMREQUEST, $this->type); |
| 235 | 235 | break; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * Always make sure to destroy Curl Resource |
| 103 | 103 | */ |
| 104 | - public function __destruct() { |
|
| 104 | + public function __destruct(){ |
|
| 105 | 105 | if ($this->status!==self::STATUS_CLOSED){ |
| 106 | 106 | curl_close($this->CurlRequest); |
| 107 | 107 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | foreach ($array as $key => $value){ |
| 141 | 141 | if (is_numeric($key)){ |
| 142 | 142 | $this->headers[] = $value; |
| 143 | - }else { |
|
| 143 | + }else{ |
|
| 144 | 144 | $this->addHeader($key, $value); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * @inheritdoc |
| 193 | 193 | */ |
| 194 | - public function getOptions() { |
|
| 194 | + public function getOptions(){ |
|
| 195 | 195 | return $this->options; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * Configure the Curl Options based on Request Type |
| 226 | 226 | */ |
| 227 | 227 | protected function configureType(){ |
| 228 | - switch ($this->type) { |
|
| 228 | + switch ($this->type){ |
|
| 229 | 229 | case 'POST': |
| 230 | 230 | $this->setOption(CURLOPT_POST, TRUE); |
| 231 | 231 | break; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * Always make sure to destroy Curl Resource |
| 103 | 103 | */ |
| 104 | - public function __destruct() { |
|
| 104 | + public function __destruct(){ |
|
| 105 | 105 | if ($this->status!==self::STATUS_CLOSED){ |
| 106 | 106 | curl_close($this->CurlRequest); |
| 107 | 107 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | foreach ($array as $key => $value){ |
| 141 | 141 | if (is_numeric($key)){ |
| 142 | 142 | $this->headers[] = $value; |
| 143 | - }else { |
|
| 143 | + } else{ |
|
| 144 | 144 | $this->addHeader($key, $value); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * @inheritdoc |
| 193 | 193 | */ |
| 194 | - public function getOptions() { |
|
| 194 | + public function getOptions(){ |
|
| 195 | 195 | return $this->options; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * Configure the Curl Options based on Request Type |
| 226 | 226 | */ |
| 227 | 227 | protected function configureType(){ |
| 228 | - switch ($this->type) { |
|
| 228 | + switch ($this->type){ |
|
| 229 | 229 | case 'POST': |
| 230 | 230 | $this->setOption(CURLOPT_POST, TRUE); |
| 231 | 231 | break; |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected $info; |
| 47 | 47 | |
| 48 | - public function __construct($curlRequest,$curlResponse = NULL){ |
|
| 48 | + public function __construct($curlRequest, $curlResponse = NULL){ |
|
| 49 | 49 | $this->CurlRequest = $curlRequest; |
| 50 | 50 | if ($curlResponse!==NULL){ |
| 51 | 51 | $this->setCurlResponse($curlResponse); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function setCurlResponse($curlResponse) { |
|
| 55 | + public function setCurlResponse($curlResponse){ |
|
| 56 | 56 | $this->extractInfo(); |
| 57 | 57 | if (!$this->error){ |
| 58 | 58 | $this->extractResponse($curlResponse); |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | protected function extractInfo(){ |
| 67 | 67 | $this->info = curl_getinfo($this->CurlRequest); |
| 68 | 68 | $this->status = $this->info['http_code']; |
| 69 | - if (curl_errno($this->CurlRequest)!== CURLE_OK){ |
|
| 69 | + if (curl_errno($this->CurlRequest)!==CURLE_OK){ |
|
| 70 | 70 | $this->error = curl_error($this->CurlRequest); |
| 71 | - }else { |
|
| 71 | + }else{ |
|
| 72 | 72 | $this->error = FALSE; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function setCurlResponse($curlResponse) { |
|
| 55 | + public function setCurlResponse($curlResponse){ |
|
| 56 | 56 | $this->extractInfo(); |
| 57 | 57 | if (!$this->error){ |
| 58 | 58 | $this->extractResponse($curlResponse); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->status = $this->info['http_code']; |
| 69 | 69 | if (curl_errno($this->CurlRequest)!== CURLE_OK){ |
| 70 | 70 | $this->error = curl_error($this->CurlRequest); |
| 71 | - }else { |
|
| 71 | + } else{ |
|
| 72 | 72 | $this->error = FALSE; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | protected $accessToken; |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - public function __construct($baseUrl,array $options = array()){ |
|
| 99 | + public function __construct($baseUrl, array $options = array()){ |
|
| 100 | 100 | $this->baseUrl = $baseUrl; |
| 101 | 101 | |
| 102 | - if (!empty($options)) { |
|
| 102 | + if (!empty($options)){ |
|
| 103 | 103 | $this->setOptions($options); |
| 104 | 104 | } |
| 105 | 105 | $this->configureURL(); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @inheritdoc |
| 128 | 128 | */ |
| 129 | - public function setAuth($accessToken) { |
|
| 129 | + public function setAuth($accessToken){ |
|
| 130 | 130 | $this->accessToken = $accessToken; |
| 131 | 131 | return $this; |
| 132 | 132 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @inheritdoc |
| 136 | 136 | */ |
| 137 | - public function setUrl($url) { |
|
| 137 | + public function setUrl($url){ |
|
| 138 | 138 | $this->Url = $url; |
| 139 | 139 | return $this; |
| 140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * @inheritdoc |
| 144 | 144 | */ |
| 145 | - public function setRequest(RequestInterface $Request) { |
|
| 145 | + public function setRequest(RequestInterface $Request){ |
|
| 146 | 146 | $this->Request = $Request; |
| 147 | 147 | return $this; |
| 148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * @inheritdoc |
| 152 | 152 | */ |
| 153 | - public function setResponse(ResponseInterface $Response) { |
|
| 153 | + public function setResponse(ResponseInterface $Response){ |
|
| 154 | 154 | $this->Response = $Response; |
| 155 | 155 | return $this; |
| 156 | 156 | } |
@@ -198,14 +198,14 @@ discard block |
||
| 198 | 198 | * @throws InvalidURLException |
| 199 | 199 | */ |
| 200 | 200 | public function execute($data = NULL){ |
| 201 | - $data = ($data === NULL?$this->Data:$data); |
|
| 201 | + $data = ($data===NULL?$this->Data:$data); |
|
| 202 | 202 | $this->configureData($data); |
| 203 | - if (is_object($this->Request)) { |
|
| 203 | + if (is_object($this->Request)){ |
|
| 204 | 204 | $this->configureRequest(); |
| 205 | 205 | $this->Request->send(); |
| 206 | 206 | $this->configureResponse(); |
| 207 | 207 | }else{ |
| 208 | - throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
|
| 208 | + throw new InvalidRequestException(get_called_class(), "Request property not configured"); |
|
| 209 | 209 | } |
| 210 | 210 | return $this; |
| 211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * @inheritdoc |
| 215 | 215 | */ |
| 216 | - public function authRequired() { |
|
| 216 | + public function authRequired(){ |
|
| 217 | 217 | return $this->_AUTH_REQUIRED; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | * @throws RequiredDataException |
| 224 | 224 | */ |
| 225 | 225 | protected function configureRequest(){ |
| 226 | - if ($this->verifyUrl()) { |
|
| 226 | + if ($this->verifyUrl()){ |
|
| 227 | 227 | $this->Request->setURL($this->Url); |
| 228 | 228 | } |
| 229 | - if ($this->verifyData() && !empty($this->Data)) { |
|
| 229 | + if ($this->verifyData() && !empty($this->Data)){ |
|
| 230 | 230 | $this->Request->setBody($this->Data); |
| 231 | 231 | } |
| 232 | 232 | $this->configureAuth(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * Configures the authentication header on the Request object |
| 248 | 248 | */ |
| 249 | 249 | protected function configureAuth(){ |
| 250 | - if ($this->authRequired()) { |
|
| 250 | + if ($this->authRequired()){ |
|
| 251 | 251 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @var $data |
| 258 | 258 | */ |
| 259 | 259 | protected function configureData($data){ |
| 260 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
| 260 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
| 261 | 261 | $data = $this->configureDefaultData($data); |
| 262 | 262 | } |
| 263 | 263 | $this->setData($data); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @return array |
| 270 | 270 | */ |
| 271 | 271 | protected function configureDefaultData(array $data){ |
| 272 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
| 272 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
| 273 | 273 | if (!isset($data[$property]) && $value!==NULL){ |
| 274 | 274 | $data[$property] = $value; |
| 275 | 275 | } |
@@ -284,9 +284,9 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | protected function configureURL(){ |
| 286 | 286 | $url = $this->_URL; |
| 287 | - if ($this->requiresOptions()) { |
|
| 288 | - foreach($this->Options as $key => $option){ |
|
| 289 | - $url = preg_replace('/(\$.*?[^\/]*)/',$option,$url,1); |
|
| 287 | + if ($this->requiresOptions()){ |
|
| 288 | + foreach ($this->Options as $key => $option){ |
|
| 289 | + $url = preg_replace('/(\$.*?[^\/]*)/', $option, $url, 1); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | $url = $this->baseUrl.$url; |
@@ -299,9 +299,9 @@ discard block |
||
| 299 | 299 | * @throws InvalidURLException |
| 300 | 300 | */ |
| 301 | 301 | protected function verifyUrl(){ |
| 302 | - $UrlArray = explode("?",$this->Url); |
|
| 303 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
| 304 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
| 302 | + $UrlArray = explode("?", $this->Url); |
|
| 303 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
| 304 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
| 305 | 305 | } |
| 306 | 306 | return true; |
| 307 | 307 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @throws RequiredDataException |
| 313 | 313 | */ |
| 314 | 314 | protected function verifyData(){ |
| 315 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 315 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
| 316 | 316 | $this->verifyDataType(); |
| 317 | 317 | } |
| 318 | 318 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | * @throws RequiredDataException |
| 328 | 328 | */ |
| 329 | 329 | protected function verifyDataType(){ |
| 330 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 331 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
| 330 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
| 331 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
| 332 | 332 | } |
| 333 | 333 | return true; |
| 334 | 334 | } |
@@ -340,13 +340,13 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | protected function verifyRequiredData(){ |
| 342 | 342 | $errors = array(); |
| 343 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 343 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
| 344 | 344 | if (!isset($this->Data[$property])){ |
| 345 | 345 | $errors[] = $property; |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | if (count($errors)>0){ |
| 349 | - throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
|
| 349 | + throw new RequiredDataException(get_called_class(), "Missing data for ".implode(",", $errors)); |
|
| 350 | 350 | } |
| 351 | 351 | return true; |
| 352 | 352 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @return bool |
| 357 | 357 | */ |
| 358 | 358 | protected function requiresOptions(){ |
| 359 | - return strpos($this->_URL,"$") === FALSE?FALSE:TRUE; |
|
| 359 | + return strpos($this->_URL, "$")===FALSE?FALSE:TRUE; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | } |
| 363 | 363 | \ No newline at end of file |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public function __construct($baseUrl,array $options = array()){ |
| 100 | 100 | $this->baseUrl = $baseUrl; |
| 101 | 101 | |
| 102 | - if (!empty($options)) { |
|
| 102 | + if (!empty($options)){ |
|
| 103 | 103 | $this->setOptions($options); |
| 104 | 104 | } |
| 105 | 105 | $this->configureURL(); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @inheritdoc |
| 128 | 128 | */ |
| 129 | - public function setAuth($accessToken) { |
|
| 129 | + public function setAuth($accessToken){ |
|
| 130 | 130 | $this->accessToken = $accessToken; |
| 131 | 131 | return $this; |
| 132 | 132 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @inheritdoc |
| 136 | 136 | */ |
| 137 | - public function setUrl($url) { |
|
| 137 | + public function setUrl($url){ |
|
| 138 | 138 | $this->Url = $url; |
| 139 | 139 | return $this; |
| 140 | 140 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * @inheritdoc |
| 144 | 144 | */ |
| 145 | - public function setRequest(RequestInterface $Request) { |
|
| 145 | + public function setRequest(RequestInterface $Request){ |
|
| 146 | 146 | $this->Request = $Request; |
| 147 | 147 | return $this; |
| 148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * @inheritdoc |
| 152 | 152 | */ |
| 153 | - public function setResponse(ResponseInterface $Response) { |
|
| 153 | + public function setResponse(ResponseInterface $Response){ |
|
| 154 | 154 | $this->Response = $Response; |
| 155 | 155 | return $this; |
| 156 | 156 | } |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | public function execute($data = NULL){ |
| 201 | 201 | $data = ($data === NULL?$this->Data:$data); |
| 202 | 202 | $this->configureData($data); |
| 203 | - if (is_object($this->Request)) { |
|
| 203 | + if (is_object($this->Request)){ |
|
| 204 | 204 | $this->configureRequest(); |
| 205 | 205 | $this->Request->send(); |
| 206 | 206 | $this->configureResponse(); |
| 207 | - }else{ |
|
| 207 | + } else{ |
|
| 208 | 208 | throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
| 209 | 209 | } |
| 210 | 210 | return $this; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * @inheritdoc |
| 215 | 215 | */ |
| 216 | - public function authRequired() { |
|
| 216 | + public function authRequired(){ |
|
| 217 | 217 | return $this->_AUTH_REQUIRED; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -223,10 +223,10 @@ discard block |
||
| 223 | 223 | * @throws RequiredDataException |
| 224 | 224 | */ |
| 225 | 225 | protected function configureRequest(){ |
| 226 | - if ($this->verifyUrl()) { |
|
| 226 | + if ($this->verifyUrl()){ |
|
| 227 | 227 | $this->Request->setURL($this->Url); |
| 228 | 228 | } |
| 229 | - if ($this->verifyData() && !empty($this->Data)) { |
|
| 229 | + if ($this->verifyData() && !empty($this->Data)){ |
|
| 230 | 230 | $this->Request->setBody($this->Data); |
| 231 | 231 | } |
| 232 | 232 | $this->configureAuth(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * Configures the authentication header on the Request object |
| 248 | 248 | */ |
| 249 | 249 | protected function configureAuth(){ |
| 250 | - if ($this->authRequired()) { |
|
| 250 | + if ($this->authRequired()){ |
|
| 251 | 251 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | protected function configureURL(){ |
| 286 | 286 | $url = $this->_URL; |
| 287 | - if ($this->requiresOptions()) { |
|
| 287 | + if ($this->requiresOptions()){ |
|
| 288 | 288 | foreach($this->Options as $key => $option){ |
| 289 | 289 | $url = preg_replace('/(\$.*?[^\/]*)/',$option,$url,1); |
| 290 | 290 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @throws RequiredDataException |
| 313 | 313 | */ |
| 314 | 314 | protected function verifyData(){ |
| 315 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
| 315 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
| 316 | 316 | $this->verifyDataType(); |
| 317 | 317 | } |
| 318 | 318 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @throws RequiredDataException |
| 328 | 328 | */ |
| 329 | 329 | protected function verifyDataType(){ |
| 330 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
| 330 | + if (gettype($this->Data) !== $this->_DATA_TYPE){ |
|
| 331 | 331 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
| 332 | 332 | } |
| 333 | 333 | return true; |