@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if (array_key_exists("image", $data)) { |
| 59 | 59 | if (class_exists("\CURLFile")) { |
| 60 | 60 | $data["image"] = new \CURLFile($data['image']); |
| 61 | - } |
|
| 62 | - else { |
|
| 61 | + } else { |
|
| 63 | 62 | $data["image"] = '@' . $data['image']; |
| 64 | 63 | } |
| 65 | 64 | } |
@@ -67,19 +67,18 @@ discard block |
||
| 67 | 67 | // Create class path |
| 68 | 68 | $this->model = ucfirst(strtolower($model)); |
| 69 | 69 | |
| 70 | - if (!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) |
|
| 71 | - throw new InvalidModelException; |
|
| 70 | + if (!class_exists("\\DirkGroenen\\Pinterest\\Models\\" . $this->model)) { |
|
| 71 | + throw new InvalidModelException; |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | // Get items and response instance |
| 74 | 75 | if (is_array($items)) { |
| 75 | 76 | $this->response = null; |
| 76 | 77 | $this->items = $items; |
| 77 | - } |
|
| 78 | - else if ($items instanceof \DirkGroenen\Pinterest\Transport\Response) { |
|
| 78 | + } else if ($items instanceof \DirkGroenen\Pinterest\Transport\Response) { |
|
| 79 | 79 | $this->response = $items; |
| 80 | 80 | $this->items = $items->data; |
| 81 | - } |
|
| 82 | - else { |
|
| 81 | + } else { |
|
| 83 | 82 | throw new PinterestException("$items needs to be an instance of Transport\Response or an array."); |
| 84 | 83 | } |
| 85 | 84 | |
@@ -89,8 +88,7 @@ discard block |
||
| 89 | 88 | // Add pagination object |
| 90 | 89 | if (isset($this->response->page) && !empty($this->response->page['next'])) { |
| 91 | 90 | $this->pagination = $this->response->page; |
| 92 | - } |
|
| 93 | - else { |
|
| 91 | + } else { |
|
| 94 | 92 | $this->pagination = false; |
| 95 | 93 | } |
| 96 | 94 | } |
@@ -54,8 +54,9 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function __construct($client_id, $client_secret, $curlbuilder = null) |
| 56 | 56 | { |
| 57 | - if ($curlbuilder == null) |
|
| 58 | - $curlbuilder = new CurlBuilder(); |
|
| 57 | + if ($curlbuilder == null) { |
|
| 58 | + $curlbuilder = new CurlBuilder(); |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | // Create new instance of Transport\Request |
| 61 | 62 | $this->request = new Request($curlbuilder); |
@@ -80,8 +81,9 @@ discard block |
||
| 80 | 81 | // Check if an instance has already been initiated |
| 81 | 82 | if (!isset($this->cachedEndpoints[$endpoint])) { |
| 82 | 83 | // Check endpoint existence |
| 83 | - if (!class_exists($class)) |
|
| 84 | - throw new InvalidEndpointException; |
|
| 84 | + if (!class_exists($class)) { |
|
| 85 | + throw new InvalidEndpointException; |
|
| 86 | + } |
|
| 85 | 87 | |
| 86 | 88 | // Create a reflection of the called class and initialize it |
| 87 | 89 | // with a reference to the request class |
@@ -167,29 +167,29 @@ |
||
| 167 | 167 | CURLOPT_SSL_VERIFYHOST => false, |
| 168 | 168 | CURLOPT_HEADER => false, |
| 169 | 169 | CURLINFO_HEADER_OUT => true |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | 172 | switch ($method) { |
| 173 | 173 | case 'POST': |
| 174 | - $ch->setOptions( array( |
|
| 174 | + $ch->setOptions(array( |
|
| 175 | 175 | CURLOPT_CUSTOMREQUEST => 'POST', |
| 176 | 176 | CURLOPT_POST => count($parameters), |
| 177 | 177 | CURLOPT_POSTFIELDS => $parameters |
| 178 | - ) ); |
|
| 178 | + )); |
|
| 179 | 179 | |
| 180 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
| 181 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 180 | + if (!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
| 181 | + $ch->setOption(CURLOPT_SAFE_UPLOAD, false); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | break; |
| 185 | 185 | case 'DELETE': |
| 186 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "DELETE" ); |
|
| 186 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 187 | 187 | break; |
| 188 | 188 | case 'PATCH': |
| 189 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "PATCH" ); |
|
| 189 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
|
| 190 | 190 | break; |
| 191 | 191 | default: |
| 192 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "GET" ); |
|
| 192 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET"); |
|
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | $mr = 5; |
| 186 | 186 | $body = null; |
| 187 | 187 | |
| 188 | - if(ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")){ |
|
| 188 | + if (ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")) { |
|
| 189 | 189 | curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, $mr > 0); |
| 190 | 190 | curl_setopt($this->curl, CURLOPT_MAXREDIRS, $mr); |
| 191 | - } else{ |
|
| 191 | + } else { |
|
| 192 | 192 | $this->setOption(CURLOPT_FOLLOWLOCATION, false); |
| 193 | 193 | |
| 194 | - if($CURLOPT_MAXREDIRS > 0){ |
|
| 194 | + if ($CURLOPT_MAXREDIRS > 0) { |
|
| 195 | 195 | $original_url = $this->getInfo(CURLINFO_EFFECTIVE_URL); |
| 196 | 196 | $newurl = $original_url; |
| 197 | 197 | |
@@ -208,24 +208,24 @@ discard block |
||
| 208 | 208 | $header = substr($response, 0, $header_size); |
| 209 | 209 | $body = substr($response, $header_size); |
| 210 | 210 | |
| 211 | - if(curl_errno($rch)){ |
|
| 211 | + if (curl_errno($rch)) { |
|
| 212 | 212 | $code = 0; |
| 213 | - } else{ |
|
| 213 | + } else { |
|
| 214 | 214 | $code = curl_getinfo($rch, CURLINFO_HTTP_CODE); |
| 215 | 215 | |
| 216 | 216 | if ($code == 301 || $code == 302) { |
| 217 | 217 | preg_match('/Location:(.*?)\n/i', $header, $matches); |
| 218 | 218 | $newurl = trim(array_pop($matches)); |
| 219 | - } else{ |
|
| 219 | + } else { |
|
| 220 | 220 | $code = 0; |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | - } while($code && --$mr); |
|
| 223 | + } while ($code && --$mr); |
|
| 224 | 224 | |
| 225 | 225 | curl_close($rch); |
| 226 | 226 | |
| 227 | - if(!$mr){ |
|
| 228 | - if ($mr === null){ |
|
| 227 | + if (!$mr) { |
|
| 228 | + if ($mr === null) { |
|
| 229 | 229 | trigger_error('Too many redirects.', E_USER_WARNING); |
| 230 | 230 | } |
| 231 | 231 | |