@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | get_instance()->load->splint('francis94c/ci-gmail', '%curl'); |
23 | 23 | get_instance()->load->splint('francis94c/ci-gmail', '%base64'); |
24 | 24 | |
25 | - if ($params != null) $this->init($params); |
|
25 | + if ($params != null) { |
|
26 | + $this->init($params); |
|
27 | + } |
|
26 | 28 | |
27 | 29 | spl_autoload_register(function($name) { |
28 | 30 | if (file_exists(APPPATH.'splints/'.self::PACKAGE."/libraries/$name.php")) { |
@@ -69,7 +71,9 @@ discard block |
||
69 | 71 | string $responseType='code', string $accessType='offline', bool $prompt=false):string |
70 | 72 | { |
71 | 73 | $redirectUri = $redirectUri ?? $this->redirectUri; |
72 | - if ($scope == null) throw new Exception("GMail scope cannot be null"); |
|
74 | + if ($scope == null) { |
|
75 | + throw new Exception("GMail scope cannot be null"); |
|
76 | + } |
|
73 | 77 | $params = [ |
74 | 78 | 'client_id' => $this->clientId, |
75 | 79 | 'redirect_uri' => $redirectUri, |
@@ -77,7 +81,9 @@ discard block |
||
77 | 81 | 'response_type' => $responseType, |
78 | 82 | 'access_type' => $accessType |
79 | 83 | ]; |
80 | - if ($prompt) $params['prompt'] = 'consent'; |
|
84 | + if ($prompt) { |
|
85 | + $params['prompt'] = 'consent'; |
|
86 | + } |
|
81 | 87 | return self::AUTH_URL . build_url_query($params, false); |
82 | 88 | } |
83 | 89 | /** |
@@ -115,7 +121,9 @@ discard block |
||
115 | 121 | curl_close($ch); |
116 | 122 | $this->lastResponse = $response; |
117 | 123 | $this->lastResponseCode = $code; |
118 | - if ($response !== false) return $this->process_response($code, $response); |
|
124 | + if ($response !== false) { |
|
125 | + return $this->process_response($code, $response); |
|
126 | + } |
|
119 | 127 | return null; |
120 | 128 | } |
121 | 129 | /** |
@@ -152,7 +160,9 @@ discard block |
||
152 | 160 | curl_close($ch); |
153 | 161 | $this->lastResponse = $response; |
154 | 162 | $this->lastResponseCode = $code; |
155 | - if ($response !== false) return $this->process_response($code, $response); |
|
163 | + if ($response !== false) { |
|
164 | + return $this->process_response($code, $response); |
|
165 | + } |
|
156 | 166 | return null; |
157 | 167 | } |
158 | 168 | /** |
@@ -169,7 +179,9 @@ discard block |
||
169 | 179 | ); |
170 | 180 | $this->lastResponse = $response; |
171 | 181 | $this->lastResponseCode = $code; |
172 | - if ($response !== false) return $this->process_response($code, $response); |
|
182 | + if ($response !== false) { |
|
183 | + return $this->process_response($code, $response); |
|
184 | + } |
|
173 | 185 | return null; |
174 | 186 | } |
175 | 187 | |
@@ -208,7 +220,9 @@ discard block |
||
208 | 220 | ); |
209 | 221 | $this->lastResponse = $response; |
210 | 222 | $this->lastResponseCode = $code; |
211 | - if ($response !== false) return $this->process_response($code, $response); |
|
223 | + if ($response !== false) { |
|
224 | + return $this->process_response($code, $response); |
|
225 | + } |
|
212 | 226 | return null; |
213 | 227 | } |
214 | 228 | |
@@ -226,7 +240,9 @@ discard block |
||
226 | 240 | ); |
227 | 241 | $this->lastResponse = $response; |
228 | 242 | $this->lastResponseCode = $code; |
229 | - if ($response !== false) return $code == 204; |
|
243 | + if ($response !== false) { |
|
244 | + return $code == 204; |
|
245 | + } |
|
230 | 246 | return false; |
231 | 247 | } |
232 | 248 | |
@@ -267,11 +283,21 @@ discard block |
||
267 | 283 | { |
268 | 284 | $query = []; |
269 | 285 | |
270 | - if ($labelIds) $query['labelIds'] = $labelIds; |
|
271 | - if ($includeSpamTrash) $query['includeSpamTrash'] = $includeSpamTrash; |
|
272 | - if ($q) $query['q'] = $q; |
|
273 | - if ($pageToken) $query['pageToken'] = $pageToken; |
|
274 | - if ($maxMessages) $query['maxResults'] = $maxMessages; |
|
286 | + if ($labelIds) { |
|
287 | + $query['labelIds'] = $labelIds; |
|
288 | + } |
|
289 | + if ($includeSpamTrash) { |
|
290 | + $query['includeSpamTrash'] = $includeSpamTrash; |
|
291 | + } |
|
292 | + if ($q) { |
|
293 | + $query['q'] = $q; |
|
294 | + } |
|
295 | + if ($pageToken) { |
|
296 | + $query['pageToken'] = $pageToken; |
|
297 | + } |
|
298 | + if ($maxMessages) { |
|
299 | + $query['maxResults'] = $maxMessages; |
|
300 | + } |
|
275 | 301 | |
276 | 302 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( |
277 | 303 | self::API . "$userId/messages" . build_url_query($query), |
@@ -322,8 +348,12 @@ discard block |
||
322 | 348 | { |
323 | 349 | $query = []; |
324 | 350 | |
325 | - if ($format != 'full' && $format != null) $query['format'] = $format; |
|
326 | - if ($metadataHeaders != null) $query['metadataHeaders'] = $metadataHeaders; |
|
351 | + if ($format != 'full' && $format != null) { |
|
352 | + $query['format'] = $format; |
|
353 | + } |
|
354 | + if ($metadataHeaders != null) { |
|
355 | + $query['metadataHeaders'] = $metadataHeaders; |
|
356 | + } |
|
327 | 357 | |
328 | 358 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( |
329 | 359 | self::API . "$userId/messages/$messageId?" . http_build_query($query), |
@@ -333,7 +363,9 @@ discard block |
||
333 | 363 | $this->lastResponse = $response; |
334 | 364 | $this->lastResponseCode = $code; |
335 | 365 | |
336 | - if ($response !== false) return new Message($response); |
|
366 | + if ($response !== false) { |
|
367 | + return new Message($response); |
|
368 | + } |
|
337 | 369 | |
338 | 370 | return null; |
339 | 371 | } |