Completed
Push — master ( 15a2ff...4bd253 )
by Francis
01:54
created
libraries/GMail.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
   function __construct($params=null) {
21 21
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
22
-    if ($params != null) $this->init($params);
22
+    if ($params != null) {
23
+      $this->init($params);
24
+    }
23 25
   }
24 26
 
25 27
   /**
@@ -59,7 +61,9 @@  discard block
 block discarded – undo
59 61
   public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline', bool $prompt=false):string
60 62
   {
61 63
     $redirectUri = $redirectUri ?? $this->redirectUri;
62
-    if ($scope == null) throw new Exception("GMail scope cannot be null");
64
+    if ($scope == null) {
65
+      throw new Exception("GMail scope cannot be null");
66
+    }
63 67
     $params = [
64 68
       'client_id'     => $this->clientId,
65 69
       'redirect_uri'  => $redirectUri,
@@ -67,7 +71,9 @@  discard block
 block discarded – undo
67 71
       'response_type' => $responseType,
68 72
       'access_type'   => $accessType
69 73
     ];
70
-    if ($prompt) $params['prompt'] = 'consent';
74
+    if ($prompt) {
75
+      $params['prompt'] = 'consent';
76
+    }
71 77
     return self::AUTH_URL . build_url_query($params, false);
72 78
   }
73 79
   /**
@@ -103,7 +109,9 @@  discard block
 block discarded – undo
103 109
     $response = curl_exec($ch);
104 110
     $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
105 111
     curl_close($ch);
106
-    if ($response !== false) return $this->process_response($code, $response);
112
+    if ($response !== false) {
113
+      return $this->process_response($code, $response);
114
+    }
107 115
     return null;
108 116
   }
109 117
   /**
@@ -137,7 +145,9 @@  discard block
 block discarded – undo
137 145
     $response = curl_exec($ch);
138 146
     $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
139 147
     curl_close($ch);
140
-    if ($response !== false) return $this->process_response($code, $response);
148
+    if ($response !== false) {
149
+      return $this->process_response($code, $response);
150
+    }
141 151
     return null;
142 152
   }
143 153
   /**
@@ -151,7 +161,9 @@  discard block
 block discarded – undo
151 161
       self::API . "$user/profile",
152 162
       ["Authorization: Bearer $this->token"]
153 163
     );
154
-    if ($response !== false) return $this->process_response($code, $response);
164
+    if ($response !== false) {
165
+      return $this->process_response($code, $response);
166
+    }
155 167
     return null;
156 168
   }
157 169
   /**
@@ -185,7 +197,9 @@  discard block
 block discarded – undo
185 197
       ["Authorization: Bearer $this->token"],
186 198
       $body
187 199
     );
188
-    if ($response !== false) return $this->process_response($code, $response);
200
+    if ($response !== false) {
201
+      return $this->process_response($code, $response);
202
+    }
189 203
     return null;
190 204
   }
191 205
   /**
@@ -200,7 +214,9 @@  discard block
 block discarded – undo
200 214
       self::API . "$userId/stop",
201 215
       ["Authorization: Bearer $this->token"]
202 216
     );
203
-    if ($response !== false) return $code == 204;
217
+    if ($response !== false) {
218
+      return $code == 204;
219
+    }
204 220
     return false;
205 221
   }
206 222
   /**
Please login to merge, or discard this patch.