Passed
Push — master ( f10fb0...03a61c )
by Francis
01:20
created
libraries/Message.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
    * @date   2019-11-22
42 42
    * @return string     [description]
43 43
    */
44
-  public function body():?string
44
+  public function body(): ?string
45 45
   {
46 46
     if (isset($this->message->payload->body->data)) {
47 47
       return base64url_decode($this->message->payload->body->data);
Please login to merge, or discard this patch.
libraries/GMail.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
   private $token;
19 19
   private $userAgent = 'CodeIgniter GMail API';
20 20
 
21
-  function __construct($params=null) {
21
+  function __construct($params = null) {
22 22
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
23 23
     get_instance()->load->splint('francis94c/ci-gmail', '%base64');
24 24
     if ($params != null) $this->init($params);
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
    * [getClientId Get Client ID.]
46 46
    * @return null|string Client ID.
47 47
    */
48
-  public function getClientId():?string {
48
+  public function getClientId(): ?string {
49 49
     return $this->clientId;
50 50
   }
51 51
   /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
    * @param  bool   $prompt       Add the prompt=consent query to the URL.
59 59
    * @return string               Authorize URL
60 60
    */
61
-  public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline', bool $prompt=false):string
61
+  public function getAuthorizeUrl(string $scope, string $redirectUri = null, string $responseType = 'code', string $accessType = 'offline', bool $prompt = false):string
62 62
   {
63 63
     $redirectUri = $redirectUri ?? $this->redirectUri;
64 64
     if ($scope == null) throw new Exception("GMail scope cannot be null");
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
       'access_type'   => $accessType
71 71
     ];
72 72
     if ($prompt) $params['prompt'] = 'consent';
73
-    return self::AUTH_URL . build_url_query($params, false);
73
+    return self::AUTH_URL.build_url_query($params, false);
74 74
   }
75 75
   /**
76 76
    * [getToken description]
77 77
    * @param  string $code [description]
78 78
    * @return [type]       [description]
79 79
    */
80
-  public function getToken(string $code, string $redirectUri=null):?array
80
+  public function getToken(string $code, string $redirectUri = null): ?array
81 81
   {
82 82
     $redirectUri = $redirectUri ?? $this->redirectUri;
83 83
     $ch = curl_init(self::TOKEN_URL);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     ]);
96 96
     $header = [
97 97
       'Content-Type: application/x-www-form-urlencoded',
98
-      'Content-Length: ' . strlen($body)
98
+      'Content-Length: '.strlen($body)
99 99
     ];
100 100
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
101 101
     curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
    * @param  string $refreshToken [description]
114 114
    * @return [type]               [description]
115 115
    */
116
-  public function refreshAccessToken(string $refreshToken):?array {
116
+  public function refreshAccessToken(string $refreshToken): ?array {
117 117
     $ch = curl_init(self::TOKEN_URL);
118 118
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
119 119
     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     ]);
129 129
     $header = [
130 130
       'Content-Type: application/x-www-form-urlencoded',
131
-      'Content-Length: ' . strlen($body)
131
+      'Content-Length: '.strlen($body)
132 132
     ];
133 133
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
134 134
     curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
    * @param  string $user [description]
149 149
    * @return [type]       [description]
150 150
    */
151
-  public function getProfile(string $user='me'):?array {
151
+  public function getProfile(string $user = 'me'): ?array {
152 152
     list($code, $response) = (new GMailCURL(GMailCURL::GET))(
153
-      self::API . "$user/profile",
153
+      self::API."$user/profile",
154 154
       ["Authorization: Bearer $this->token"]
155 155
     );
156 156
     if ($response !== false) return $this->process_response($code, $response);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
    * @param  string $labelFilterAction [description]
169 169
    * @return [type]                    [description]
170 170
    */
171
-  public function watch(string $topic, $labelIds=null, string $userId='me', string $labelFilterAction='include'):?array {
171
+  public function watch(string $topic, $labelIds = null, string $userId = 'me', string $labelFilterAction = 'include'): ?array {
172 172
     $body = [
173 173
       'topicName'         => $topic,
174 174
       'labelFilterAction' => $labelFilterAction
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     }
184 184
 
185 185
     list($code, $response) = (new GMailCURL(GMailCURL::POST))(
186
-      self::API . "$userId/watch",
186
+      self::API."$userId/watch",
187 187
       ["Authorization: Bearer $this->token"],
188 188
       $body
189 189
     );
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
    * @param  string     $userId ID or Email Address of the user.
197 197
    * @return bool               [description]
198 198
    */
199
-  public function endWatch(string $userId='me'):bool
199
+  public function endWatch(string $userId = 'me'):bool
200 200
   {
201 201
     list($code, $response) = (new GMailCURL(GMailCURL::POST))(
202
-      self::API . "$userId/stop",
202
+      self::API."$userId/stop",
203 203
       ["Authorization: Bearer $this->token"]
204 204
     );
205 205
     if ($response !== false) return $code == 204;
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
    * @param  string     $userID [description]
212 212
    * @return null|array         [description]
213 213
    */
214
-  public function getLabels(string $userId='me'):?array
214
+  public function getLabels(string $userId = 'me'): ?array
215 215
   {
216 216
     list($code, $response) = (new GMailCURL(GMailCURL::GET))(
217
-      self::API . "$userId/labels",
217
+      self::API."$userId/labels",
218 218
       ["Authorization: Bearer $this->token"]
219 219
     );
220 220
     if ($response !== false) {
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
    * @param  [type]     $truncateAfter    [description]
235 235
    * @return [type]                       [description]
236 236
    */
237
-  public function getMessages(string $userId='me', array $labelIds=null,
238
-  string $q=null, int $maxMessages=null, string $pageToken=null, bool $includeSpamTrash=false,
239
-  $truncateAfter=null):?object
237
+  public function getMessages(string $userId = 'me', array $labelIds = null,
238
+  string $q = null, int $maxMessages = null, string $pageToken = null, bool $includeSpamTrash = false,
239
+  $truncateAfter = null): ?object
240 240
   {
241 241
     $query = [];
242 242
 
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
     if ($maxMessages != null) $query['maxResults'] = $maxMessages;
248 248
 
249 249
     list($code, $response) = (new GMailCURL(GMailCURL::GET))(
250
-      self::API . "$userId/messages?" . http_build_query($query),
250
+      self::API."$userId/messages?".http_build_query($query),
251 251
       ["Authorization: Bearer $this->token"]
252 252
     );
253 253
 
254 254
     if ($response !== false) {
255 255
       if ($truncateAfter != null && $code == 200) {
256 256
         $response = json_decode($response);
257
-        $response->messages = array_filter($response->messages, function ($e) use ($truncateAfter) {
257
+        $response->messages = array_filter($response->messages, function($e) use ($truncateAfter) {
258 258
           return strcmp($truncateAfter, $e->id) <= 0;
259 259
         });
260 260
         $response->{self::HTTP_CODE} = $code;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
    * @param  [type]       $metadataHeaders [description]
276 276
    * @return Message|null                  [description]
277 277
    */
278
-  public function getMessage(string $userId='me', string $messageId,
279
-  string $format='full', array $metadataHeaders=null):?Message
278
+  public function getMessage(string $userId = 'me', string $messageId,
279
+  string $format = 'full', array $metadataHeaders = null): ?Message
280 280
   {
281 281
     $query = [];
282 282
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     if ($metadataHeaders != null) $query['metadataHeaders'] = $metadataHeaders;
285 285
 
286 286
     list($code, $response) = (new GMailCURL(GMailCURL::GET))(
287
-      self::API . "$userId/messages/$messageId?" . http_build_query($query),
287
+      self::API."$userId/messages/$messageId?".http_build_query($query),
288 288
       ["Authorization: Bearer $this->token"]
289 289
     );
290 290
 
Please login to merge, or discard this patch.
helpers/base64_helper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
    *
12 12
    * @return string|bool          Decoded String.
13 13
    */
14
-  function base64url_decode(string $data, bool $strict=false) {
14
+  function base64url_decode(string $data, bool $strict = false) {
15 15
     $b64 = strtr($data, '-_', '+/');
16 16
     return base64_decode($b64, $strict);
17 17
   }
Please login to merge, or discard this patch.