@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function __construct($client_id, $client_secret, $curlbuilder = null) |
57 | 57 | { |
58 | - if($curlbuilder == null) |
|
59 | - $curlbuilder = new CurlBuilder(); |
|
58 | + if($curlbuilder == null) { |
|
59 | + $curlbuilder = new CurlBuilder(); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | // Create new instance of Transport\Request |
62 | 63 | $this->request = new Request( $curlbuilder ); |
@@ -81,8 +82,9 @@ discard block |
||
81 | 82 | // Check if an instance has already been initiated |
82 | 83 | if(!isset($this->cachedEndpoints[$endpoint])){ |
83 | 84 | // Check endpoint existence |
84 | - if(!class_exists($class)) |
|
85 | - throw new InvalidEndpointException; |
|
85 | + if(!class_exists($class)) { |
|
86 | + throw new InvalidEndpointException; |
|
87 | + } |
|
86 | 88 | |
87 | 89 | // Create a reflection of the called class and initialize it |
88 | 90 | // with a reference to the request class |
@@ -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 | } |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | // Fill the model |
52 | 52 | if( is_array($modeldata) ){ |
53 | 53 | $this->fill($modeldata); |
54 | - } |
|
55 | - else if( $modeldata instanceof \DirkGroenen\Pinterest\Transport\Response ){ |
|
54 | + } else if( $modeldata instanceof \DirkGroenen\Pinterest\Transport\Response ){ |
|
56 | 55 | $this->fill($modeldata->data); |
57 | 56 | } |
58 | 57 | } |
@@ -82,8 +81,7 @@ discard block |
||
82 | 81 | { |
83 | 82 | if($this->isFillable($key)){ |
84 | 83 | $this->attributes[$key] = $value; |
85 | - } |
|
86 | - else{ |
|
84 | + } else{ |
|
87 | 85 | throw new PinterestException( sprintf("%s is not a fillable attribute.", $key) ); |
88 | 86 | } |
89 | 87 | } |
@@ -165,10 +165,11 @@ discard block |
||
165 | 165 | $result = array(); |
166 | 166 | foreach(explode("\n", $headers) as $row){ |
167 | 167 | $header = explode(':', $row, 2); |
168 | - if (count($header) == 2) |
|
169 | - $result[$header[0]] = trim($header[1]); |
|
170 | - else |
|
171 | - $result[] = $header[0]; |
|
168 | + if (count($header) == 2) { |
|
169 | + $result[$header[0]] = trim($header[1]); |
|
170 | + } else { |
|
171 | + $result[] = $header[0]; |
|
172 | + } |
|
172 | 173 | } |
173 | 174 | return $result; |
174 | 175 | } |
@@ -189,8 +190,7 @@ discard block |
||
189 | 190 | if(ini_get("open_basedir") == "" && ini_get("safe_mode" == "Off")){ |
190 | 191 | curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, $mr > 0); |
191 | 192 | curl_setopt($this->curl, CURLOPT_MAXREDIRS, $mr); |
192 | - } |
|
193 | - else{ |
|
193 | + } else{ |
|
194 | 194 | $this->setOption(CURLOPT_FOLLOWLOCATION, false); |
195 | 195 | |
196 | 196 | if($mr > 0){ |
@@ -213,15 +213,13 @@ discard block |
||
213 | 213 | |
214 | 214 | if(curl_errno($rch)){ |
215 | 215 | $code = 0; |
216 | - } |
|
217 | - else{ |
|
216 | + } else{ |
|
218 | 217 | $code = curl_getinfo($rch, CURLINFO_HTTP_CODE); |
219 | 218 | |
220 | 219 | if ($code == 301 || $code == 302) { |
221 | 220 | preg_match('/Location:(.*?)\n/i', $header, $matches); |
222 | 221 | $newurl = trim(array_pop($matches)); |
223 | - } |
|
224 | - else{ |
|
222 | + } else{ |
|
225 | 223 | $code = 0; |
226 | 224 | } |
227 | 225 | } |
@@ -232,8 +230,7 @@ discard block |
||
232 | 230 | if(!$mr){ |
233 | 231 | if ($maxredirect === null){ |
234 | 232 | trigger_error('Too many redirects.', E_USER_WARNING); |
235 | - } |
|
236 | - else{ |
|
233 | + } else{ |
|
237 | 234 | $maxredirect = 0; |
238 | 235 | } |
239 | 236 |
@@ -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': |