@@ -10,7 +10,9 @@ |
||
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)."&"; |
@@ -16,7 +16,9 @@ |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | function __invoke(string $url, array $header=[], array $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 |
@@ -19,7 +19,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** |