Completed
Push — master ( f26ca7...1a40fa )
by Francis
01:19
created
helpers/curl_helper.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
    * @return string             [description]
11 11
    */
12 12
   function build_url_query(array $params, bool $urlEncode=true):?string {
13
-    if ($params == null) return null;
13
+    if ($params == null) {
14
+      return null;
15
+    }
14 16
     $queryString = '?';
15 17
     foreach($params as $key => $val) {
16 18
       $queryString .= $key."=".($urlEncode ? rawurlencode($val) : $val)."&";
Please login to merge, or discard this patch.
libraries/GMailUtil.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
   }
17 17
 
18 18
   function __invoke(string $url, array $header=[], mixed $body=null):array {
19
-    if ($body != null) $body = json_encode($body);
19
+    if ($body != null) {
20
+      $body = json_encode($body);
21
+    }
20 22
 
21 23
     $ch = curl_init($url);
22 24
 
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
     // Header.
30 32
     $header[] = 'Content-Type: application/json';
31 33
     $header[] = 'Content-Length: 0';
32
-    if ($body != null) $header[] = 'Content-Length: '.strlen($body);
34
+    if ($body != null) {
35
+      $header[] = 'Content-Length: '.strlen($body);
36
+    }
33 37
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
34 38
     curl_setopt(CURLOPT_USERAGENT, $this->userAgent);
35 39
     // Request Method and Body.
Please login to merge, or discard this patch.
libraries/GMail.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
   function __construct($params=null) {
20 20
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
21
-    if ($params != null) $this->init($params);
21
+    if ($params != null) {
22
+      $this->init($params);
23
+    }
22 24
   }
23 25
 
24 26
   /**
@@ -57,7 +59,9 @@  discard block
 block discarded – undo
57 59
    */
58 60
   public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline', bool $prompt=false):string {
59 61
     $redirectUri = $redirectUri ?? $this->redirectUri;
60
-    if ($scope == null) throw new Exception("GMail scope cannot be null");
62
+    if ($scope == null) {
63
+      throw new Exception("GMail scope cannot be null");
64
+    }
61 65
     $params = [
62 66
       'client_id'     => $this->clientId,
63 67
       'redirect_uri'  => $redirectUri,
@@ -65,7 +69,9 @@  discard block
 block discarded – undo
65 69
       'response_type' => $responseType,
66 70
       'access_type'   => $accessType
67 71
     ];
68
-    if ($prompt) $params['prompt'] = 'consent';
72
+    if ($prompt) {
73
+      $params['prompt'] = 'consent';
74
+    }
69 75
     return self::AUTH_URL . build_url_query($params, false);
70 76
   }
71 77
   /**
@@ -84,7 +90,9 @@  discard block
 block discarded – undo
84 90
         'grant_type'    => 'authorization_code'
85 91
       ], false)
86 92
     );
87
-    if ($response !== false)$this->process_response($code, $response);
93
+    if ($response !== false) {
94
+      $this->process_response($code, $response);
95
+    }
88 96
     return null;
89 97
   }
90 98
   /**
@@ -97,7 +105,9 @@  discard block
 block discarded – undo
97 105
       self::API . "users/$user/profile",
98 106
       ["Authorization: Bearer $this->token"]
99 107
     );
100
-    if ($response !== false) return $this->process_response($code, $response);
108
+    if ($response !== false) {
109
+      return $this->process_response($code, $response);
110
+    }
101 111
     return null;
102 112
   }
103 113
   /**
Please login to merge, or discard this patch.