| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | * @covers JWT::__construct | 
| 21 | 21 | */ | 
| 22 | 22 |    public static function setUpBeforeClass(): void { | 
| 23 | - self::$ci =& get_instance(); | |
| 23 | + self::$ci = & get_instance(); | |
| 24 | 24 | } | 
| 25 | 25 | /** | 
| 26 | 26 | * [testLoadPackage description] | 
| @@ -9,10 +9,10 @@ | ||
| 9 | 9 | * @param boolean $urlEncode [description] | 
| 10 | 10 | * @return string [description] | 
| 11 | 11 | */ | 
| 12 | -  function build_url_query(array $params, bool $urlEncode=true):?string { | |
| 12 | +  function build_url_query(array $params, bool $urlEncode = true): ?string { | |
| 13 | 13 | if ($params == null) return null; | 
| 14 | 14 | $queryString = '?'; | 
| 15 | -    foreach($params as $key => $val) { | |
| 15 | +    foreach ($params as $key => $val) { | |
| 16 | 16 | $queryString .= $key."=".($urlEncode ? rawurlencode($val) : $val)."&"; | 
| 17 | 17 | } | 
| 18 | 18 | return substr($queryString, 0, strlen($queryString) - 1); | 
| @@ -41,7 +41,7 @@ | ||
| 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); | 
| @@ -11,7 +11,7 @@ | ||
| 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 | } | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 | private $token; | 
| 16 | 16 | private $userAgent = 'CodeIgniter GMail API'; | 
| 17 | 17 | |
| 18 | - function __construct($params=null) | |
| 18 | + function __construct($params = null) | |
| 19 | 19 |    { | 
| 20 | 20 |      get_instance()->load->splint('francis94c/ci-gmail', '%curl'); | 
| 21 | 21 |      get_instance()->load->splint('francis94c/ci-gmail', '%base64'); | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | if ($params != null) $this->init($params); | 
| 24 | 24 | |
| 25 | 25 |      spl_autoload_register(function($name) { | 
| 26 | - $oldPath = set_include_path(APPPATH . 'splints/' . self::PACKAGE . '/libraries'); | |
| 26 | + $oldPath = set_include_path(APPPATH.'splints/'.self::PACKAGE.'/libraries'); | |
| 27 | 27 |        require("$name.php"); | 
| 28 | 28 | set_include_path($oldPath); | 
| 29 | 29 | }); | 
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 | * [getClientId Get Client ID.] | 
| 51 | 51 | * @return null|string Client ID. | 
| 52 | 52 | */ | 
| 53 | -  public function getClientId():?string { | |
| 53 | +  public function getClientId(): ?string { | |
| 54 | 54 | return $this->clientId; | 
| 55 | 55 | } | 
| 56 | 56 | /** | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | * @param bool $prompt Add the prompt=consent query to the URL. | 
| 64 | 64 | * @return string Authorize URL | 
| 65 | 65 | */ | 
| 66 | - public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline', bool $prompt=false):string | |
| 66 | + public function getAuthorizeUrl(string $scope, string $redirectUri = null, string $responseType = 'code', string $accessType = 'offline', bool $prompt = false):string | |
| 67 | 67 |    { | 
| 68 | 68 | $redirectUri = $redirectUri ?? $this->redirectUri; | 
| 69 | 69 |      if ($scope == null) throw new Exception("GMail scope cannot be null"); | 
| @@ -75,14 +75,14 @@ discard block | ||
| 75 | 75 | 'access_type' => $accessType | 
| 76 | 76 | ]; | 
| 77 | 77 | if ($prompt) $params['prompt'] = 'consent'; | 
| 78 | - return self::AUTH_URL . build_url_query($params, false); | |
| 78 | + return self::AUTH_URL.build_url_query($params, false); | |
| 79 | 79 | } | 
| 80 | 80 | /** | 
| 81 | 81 | * [getToken description] | 
| 82 | 82 | * @param string $code [description] | 
| 83 | 83 | * @return [type] [description] | 
| 84 | 84 | */ | 
| 85 | - public function getToken(string $code, string $redirectUri=null):?array | |
| 85 | + public function getToken(string $code, string $redirectUri = null): ?array | |
| 86 | 86 |    { | 
| 87 | 87 | $redirectUri = $redirectUri ?? $this->redirectUri; | 
| 88 | 88 | $ch = curl_init(self::TOKEN_URL); | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | ]); | 
| 101 | 101 | $header = [ | 
| 102 | 102 | 'Content-Type: application/x-www-form-urlencoded', | 
| 103 | - 'Content-Length: ' . strlen($body) | |
| 103 | + 'Content-Length: '.strlen($body) | |
| 104 | 104 | ]; | 
| 105 | 105 | curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | 
| 106 | 106 | curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | * @param string $refreshToken [description] | 
| 119 | 119 | * @return [type] [description] | 
| 120 | 120 | */ | 
| 121 | -  public function refreshAccessToken(string $refreshToken):?array { | |
| 121 | +  public function refreshAccessToken(string $refreshToken): ?array { | |
| 122 | 122 | $ch = curl_init(self::TOKEN_URL); | 
| 123 | 123 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | 
| 124 | 124 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); | 
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 | ]); | 
| 134 | 134 | $header = [ | 
| 135 | 135 | 'Content-Type: application/x-www-form-urlencoded', | 
| 136 | - 'Content-Length: ' . strlen($body) | |
| 136 | + 'Content-Length: '.strlen($body) | |
| 137 | 137 | ]; | 
| 138 | 138 | curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | 
| 139 | 139 | curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); | 
| @@ -153,9 +153,9 @@ discard block | ||
| 153 | 153 | * @param string $user [description] | 
| 154 | 154 | * @return [type] [description] | 
| 155 | 155 | */ | 
| 156 | -  public function getProfile(string $user='me'):?array { | |
| 156 | +  public function getProfile(string $user = 'me'): ?array { | |
| 157 | 157 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( | 
| 158 | - self::API . "$user/profile", | |
| 158 | + self::API."$user/profile", | |
| 159 | 159 | ["Authorization: Bearer $this->token"] | 
| 160 | 160 | ); | 
| 161 | 161 | if ($response !== false) return $this->process_response($code, $response); | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 | * @param string $labelFilterAction [description] | 
| 174 | 174 | * @return [type] [description] | 
| 175 | 175 | */ | 
| 176 | -  public function watch(string $topic, $labelIds=null, string $userId='me', string $labelFilterAction='include'):?array { | |
| 176 | +  public function watch(string $topic, $labelIds = null, string $userId = 'me', string $labelFilterAction = 'include'): ?array { | |
| 177 | 177 | $body = [ | 
| 178 | 178 | 'topicName' => $topic, | 
| 179 | 179 | 'labelFilterAction' => $labelFilterAction | 
| @@ -188,7 +188,7 @@ discard block | ||
| 188 | 188 | } | 
| 189 | 189 | |
| 190 | 190 | list($code, $response) = (new GMailCURL(GMailCURL::POST))( | 
| 191 | - self::API . "$userId/watch", | |
| 191 | + self::API."$userId/watch", | |
| 192 | 192 | ["Authorization: Bearer $this->token"], | 
| 193 | 193 | $body | 
| 194 | 194 | ); | 
| @@ -201,10 +201,10 @@ discard block | ||
| 201 | 201 | * @param string $userId ID or Email Address of the user. | 
| 202 | 202 | * @return bool [description] | 
| 203 | 203 | */ | 
| 204 | - public function endWatch(string $userId='me'):bool | |
| 204 | + public function endWatch(string $userId = 'me'):bool | |
| 205 | 205 |    { | 
| 206 | 206 | list($code, $response) = (new GMailCURL(GMailCURL::POST))( | 
| 207 | - self::API . "$userId/stop", | |
| 207 | + self::API."$userId/stop", | |
| 208 | 208 | ["Authorization: Bearer $this->token"] | 
| 209 | 209 | ); | 
| 210 | 210 | if ($response !== false) return $code == 204; | 
| @@ -216,10 +216,10 @@ discard block | ||
| 216 | 216 | * @param string $userID [description] | 
| 217 | 217 | * @return null|array [description] | 
| 218 | 218 | */ | 
| 219 | - public function getLabels(string $userId='me'):?array | |
| 219 | + public function getLabels(string $userId = 'me'): ?array | |
| 220 | 220 |    { | 
| 221 | 221 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( | 
| 222 | - self::API . "$userId/labels", | |
| 222 | + self::API."$userId/labels", | |
| 223 | 223 | ["Authorization: Bearer $this->token"] | 
| 224 | 224 | ); | 
| 225 | 225 |      if ($response !== false) { | 
| @@ -239,9 +239,9 @@ discard block | ||
| 239 | 239 | * @param [type] $truncateAfter [description] | 
| 240 | 240 | * @return [type] [description] | 
| 241 | 241 | */ | 
| 242 | - public function getMessages(string $userId='me', array $labelIds=null, | |
| 243 | - string $q=null, int $maxMessages=null, string $pageToken=null, bool $includeSpamTrash=false, | |
| 244 | - $truncateAfter=null):?object | |
| 242 | + public function getMessages(string $userId = 'me', array $labelIds = null, | |
| 243 | + string $q = null, int $maxMessages = null, string $pageToken = null, bool $includeSpamTrash = false, | |
| 244 | + $truncateAfter = null): ?object | |
| 245 | 245 |    { | 
| 246 | 246 | $query = []; | 
| 247 | 247 | |
| @@ -252,14 +252,14 @@ discard block | ||
| 252 | 252 | if ($maxMessages != null) $query['maxResults'] = $maxMessages; | 
| 253 | 253 | |
| 254 | 254 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( | 
| 255 | - self::API . "$userId/messages?" . http_build_query($query), | |
| 255 | + self::API."$userId/messages?".http_build_query($query), | |
| 256 | 256 | ["Authorization: Bearer $this->token"] | 
| 257 | 257 | ); | 
| 258 | 258 | |
| 259 | 259 |      if ($response !== false) { | 
| 260 | 260 |        if ($truncateAfter != null && $code == 200) { | 
| 261 | 261 | $response = json_decode($response); | 
| 262 | -        $response->messages = array_filter($response->messages, function ($e) use ($truncateAfter) { | |
| 262 | +        $response->messages = array_filter($response->messages, function($e) use ($truncateAfter) { | |
| 263 | 263 | return strcmp($truncateAfter, $e->id) <= 0; | 
| 264 | 264 | }); | 
| 265 | 265 |          $response->{self::HTTP_CODE} = $code; | 
| @@ -280,8 +280,8 @@ discard block | ||
| 280 | 280 | * @param [type] $metadataHeaders [description] | 
| 281 | 281 | * @return Message|null [description] | 
| 282 | 282 | */ | 
| 283 | - public function getMessage(string $userId='me', string $messageId, | |
| 284 | - string $format='full', array $metadataHeaders=null):?Message | |
| 283 | + public function getMessage(string $userId = 'me', string $messageId, | |
| 284 | + string $format = 'full', array $metadataHeaders = null): ?Message | |
| 285 | 285 |    { | 
| 286 | 286 | $query = []; | 
| 287 | 287 | |
| @@ -289,7 +289,7 @@ discard block | ||
| 289 | 289 | if ($metadataHeaders != null) $query['metadataHeaders'] = $metadataHeaders; | 
| 290 | 290 | |
| 291 | 291 | list($code, $response) = (new GMailCURL(GMailCURL::GET))( | 
| 292 | - self::API . "$userId/messages/$messageId?" . http_build_query($query), | |
| 292 | + self::API."$userId/messages/$messageId?".http_build_query($query), | |
| 293 | 293 | ["Authorization: Bearer $this->token"] | 
| 294 | 294 | ); | 
| 295 | 295 | |
| @@ -10,12 +10,12 @@ discard block | ||
| 10 | 10 | private $method; | 
| 11 | 11 | private $userAgent; | 
| 12 | 12 | |
| 13 | -  function __construct(string $method, string $userAgent='CodeIgniter GMail API') { | |
| 13 | +  function __construct(string $method, string $userAgent = 'CodeIgniter GMail API') { | |
| 14 | 14 | $this->method = $method; | 
| 15 | 15 | $this->userAgent = $userAgent; | 
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | -  function __invoke(string $url, array $header=[], array $body=null):array { | |
| 18 | +  function __invoke(string $url, array $header = [], array $body = null):array { | |
| 19 | 19 | if ($body != null) $body = json_encode($body); | 
| 20 | 20 | |
| 21 | 21 | $ch = curl_init($url); | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | } | 
| 29 | 29 | // Header. | 
| 30 | 30 | $header[] = 'Content-Type: application/json'; | 
| 31 | -    if ($body != null)  { | |
| 31 | +    if ($body != null) { | |
| 32 | 32 | $header[] = 'Content-Length: '.strlen($body); | 
| 33 | 33 |      } else { | 
| 34 | 34 | $header[] = 'Content-Length: 0'; |