@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param CurlBuilder $curlbuilder |
| 51 | 51 | */ |
| 52 | - public function __construct( CurlBuilder $curlbuilder ) |
|
| 52 | + public function __construct(CurlBuilder $curlbuilder) |
|
| 53 | 53 | { |
| 54 | 54 | $this->curlbuilder = $curlbuilder; |
| 55 | 55 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @access public |
| 61 | 61 | * @param string $token |
| 62 | 62 | */ |
| 63 | - public function setAccessToken( $token ) |
|
| 63 | + public function setAccessToken($token) |
|
| 64 | 64 | { |
| 65 | 65 | $this->access_token = $token; |
| 66 | 66 | } |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @param array $parameters |
| 74 | 74 | * @return [type] |
| 75 | 75 | */ |
| 76 | - public function get( $endpoint, array $parameters = array() ) |
|
| 76 | + public function get($endpoint, array $parameters = array()) |
|
| 77 | 77 | { |
| 78 | - if(!empty($parameters)) { |
|
| 78 | + if (!empty($parameters)) { |
|
| 79 | 79 | $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); |
| 80 | 80 | } |
| 81 | 81 | else { |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | * @param array $parameters |
| 94 | 94 | * @return [type] |
| 95 | 95 | */ |
| 96 | - public function post( $path, array $parameters = array() ) |
|
| 96 | + public function post($path, array $parameters = array()) |
|
| 97 | 97 | { |
| 98 | - return $this->execute("POST", sprintf("%s%s", $this->host, $path), $parameters ); |
|
| 98 | + return $this->execute("POST", sprintf("%s%s", $this->host, $path), $parameters); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | * @param array $parameters |
| 107 | 107 | * @return [type] |
| 108 | 108 | */ |
| 109 | - public function delete( $path, array $parameters = array() ) |
|
| 109 | + public function delete($path, array $parameters = array()) |
|
| 110 | 110 | { |
| 111 | - return $this->execute("DELETE", sprintf("%s%s", $this->host, $path) . "/", $parameters ); |
|
| 111 | + return $this->execute("DELETE", sprintf("%s%s", $this->host, $path) . "/", $parameters); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | * @param array $parameters |
| 120 | 120 | * @return [type] |
| 121 | 121 | */ |
| 122 | - public function update( $path, array $parameters = array() ) |
|
| 122 | + public function update($path, array $parameters = array()) |
|
| 123 | 123 | { |
| 124 | - return $this->execute("PATCH", sprintf("%s%s", $this->host, $path) . "/", $parameters ); |
|
| 124 | + return $this->execute("PATCH", sprintf("%s%s", $this->host, $path) . "/", $parameters); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | * @param array $headers |
| 147 | 147 | * @return mixed |
| 148 | 148 | */ |
| 149 | - public function execute( $method, $apiCall, array $parameters = array(), $headers = array() ) |
|
| 149 | + public function execute($method, $apiCall, array $parameters = array(), $headers = array()) |
|
| 150 | 150 | { |
| 151 | 151 | // Check if the access token needs to be added |
| 152 | - if($this->access_token != null){ |
|
| 152 | + if ($this->access_token != null) { |
|
| 153 | 153 | $headers = array_merge($headers, array( |
| 154 | 154 | "Authorization: Bearer " . $this->access_token, |
| 155 | 155 | "Content-ype: multipart/form-data", |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $ch = $this->curlbuilder->create(); |
| 161 | 161 | |
| 162 | 162 | // Set default options |
| 163 | - $ch->setOptions( array( |
|
| 163 | + $ch->setOptions(array( |
|
| 164 | 164 | CURLOPT_URL => $apiCall, |
| 165 | 165 | CURLOPT_HTTPHEADER => $headers, |
| 166 | 166 | CURLOPT_CONNECTTIMEOUT => 20, |
@@ -170,28 +170,28 @@ discard block |
||
| 170 | 170 | CURLOPT_SSL_VERIFYHOST => false, |
| 171 | 171 | CURLOPT_HEADER => false, |
| 172 | 172 | CURLINFO_HEADER_OUT => true |
| 173 | - ) ); |
|
| 173 | + )); |
|
| 174 | 174 | |
| 175 | 175 | switch ($method) { |
| 176 | 176 | case 'POST': |
| 177 | - $ch->setOptions( array( |
|
| 177 | + $ch->setOptions(array( |
|
| 178 | 178 | CURLOPT_CUSTOMREQUEST => 'POST', |
| 179 | 179 | CURLOPT_POST => count($parameters), |
| 180 | 180 | CURLOPT_POSTFIELDS => $parameters |
| 181 | - ) ); |
|
| 181 | + )); |
|
| 182 | 182 | |
| 183 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
| 184 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 183 | + if (!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
| 184 | + $ch->setOption(CURLOPT_SAFE_UPLOAD, false); |
|
| 185 | 185 | |
| 186 | 186 | break; |
| 187 | 187 | case 'DELETE': |
| 188 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "DELETE" ); |
|
| 188 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 189 | 189 | break; |
| 190 | 190 | case 'PATCH': |
| 191 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "PATCH" ); |
|
| 191 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
|
| 192 | 192 | break; |
| 193 | 193 | default: |
| 194 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "GET" ); |
|
| 194 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET"); |
|
| 195 | 195 | break; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,16 +200,16 @@ discard block |
||
| 200 | 200 | $response_data = $ch->execute(); |
| 201 | 201 | |
| 202 | 202 | // Check if we have a valid response |
| 203 | - if ( !$response_data || $ch->hasErrors() ) { |
|
| 204 | - throw new PinterestException( 'Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber() ); |
|
| 203 | + if (!$response_data || $ch->hasErrors()) { |
|
| 204 | + throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber()); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // Initiate the response |
| 208 | 208 | $response = new Response($response_data, $ch); |
| 209 | 209 | |
| 210 | 210 | // Check the response code |
| 211 | - if ( $response->getResponseCode() >= 400 ) { |
|
| 212 | - throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode() ); |
|
| 211 | + if ($response->getResponseCode() >= 400) { |
|
| 212 | + throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode()); |
|
| 213 | 213 | } |
| 214 | 214 | $this->headers = $ch->getHeaders(); |
| 215 | 215 | |
@@ -77,8 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if(!empty($parameters)) { |
| 79 | 79 | $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); |
| 80 | - } |
|
| 81 | - else { |
|
| 80 | + } else { |
|
| 82 | 81 | $path = $endpoint; |
| 83 | 82 | } |
| 84 | 83 | |
@@ -180,8 +179,9 @@ discard block |
||
| 180 | 179 | CURLOPT_POSTFIELDS => $parameters |
| 181 | 180 | ) ); |
| 182 | 181 | |
| 183 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
| 184 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 182 | + if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
| 183 | + $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | break; |
| 187 | 187 | case 'DELETE': |