Passed
Push — master ( 3e41fe...15a2ff )
by Francis
01:32
created
phpunit/GMailAPITest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
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]
Please login to merge, or discard this patch.
helpers/curl_helper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
libraries/GMailUtil.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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';
Please login to merge, or discard this patch.
libraries/GMail.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
   private $token;
18 18
   private $userAgent = 'CodeIgniter GMail API';
19 19
 
20
-  function __construct($params=null) {
20
+  function __construct($params = null) {
21 21
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
22 22
     if ($params != null) $this->init($params);
23 23
   }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
    * [getClientId Get Client ID.]
44 44
    * @return null|string Client ID.
45 45
    */
46
-  public function getClientId():?string {
46
+  public function getClientId(): ?string {
47 47
     return $this->clientId;
48 48
   }
49 49
   /**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
    * @param  bool   $prompt       Add the prompt=consent query to the URL.
57 57
    * @return string               Authorize URL
58 58
    */
59
-  public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline', bool $prompt=false):string {
59
+  public function getAuthorizeUrl(string $scope, string $redirectUri = null, string $responseType = 'code', string $accessType = 'offline', bool $prompt = false):string {
60 60
     $redirectUri = $redirectUri ?? $this->redirectUri;
61 61
     if ($scope == null) throw new Exception("GMail scope cannot be null");
62 62
     $params = [
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
       'access_type'   => $accessType
68 68
     ];
69 69
     if ($prompt) $params['prompt'] = 'consent';
70
-    return self::AUTH_URL . build_url_query($params, false);
70
+    return self::AUTH_URL.build_url_query($params, false);
71 71
   }
72 72
   /**
73 73
    * [getToken description]
74 74
    * @param  string $code [description]
75 75
    * @return [type]       [description]
76 76
    */
77
-  public function getToken(string $code, string $redirectUri=null):?array {
77
+  public function getToken(string $code, string $redirectUri = null): ?array {
78 78
     $redirectUri = $redirectUri ?? $this->redirectUri;
79 79
     $ch = curl_init(self::TOKEN_URL);
80 80
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     ]);
92 92
     $header = [
93 93
       'Content-Type: application/x-www-form-urlencoded',
94
-      'Content-Length: ' . strlen($body)
94
+      'Content-Length: '.strlen($body)
95 95
     ];
96 96
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
97 97
     curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
    * @param  string $refreshToken [description]
110 110
    * @return [type]               [description]
111 111
    */
112
-  public function refreshAccessToken(string $refreshToken):?array {
112
+  public function refreshAccessToken(string $refreshToken): ?array {
113 113
     $ch = curl_init(self::TOKEN_URL);
114 114
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
115 115
     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     ]);
125 125
     $header = [
126 126
       'Content-Type: application/x-www-form-urlencoded',
127
-      'Content-Length: ' . strlen($body)
127
+      'Content-Length: '.strlen($body)
128 128
     ];
129 129
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
130 130
     curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
    * @param  string $user [description]
145 145
    * @return [type]       [description]
146 146
    */
147
-  public function getProfile(string $user='me'):?array {
147
+  public function getProfile(string $user = 'me'): ?array {
148 148
     list($code, $response) = (new GMailCURL(GMailCURL::GET))(
149
-      self::API . "$user/profile",
149
+      self::API."$user/profile",
150 150
       ["Authorization: Bearer $this->token"]
151 151
     );
152 152
     if ($response !== false) return $this->process_response($code, $response);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    * @param  string $labelFilterAction [description]
165 165
    * @return [type]                    [description]
166 166
    */
167
-  public function watch(string $topic, $labelIds=null, string $userId='me', string $labelFilterAction='include'):?array {
167
+  public function watch(string $topic, $labelIds = null, string $userId = 'me', string $labelFilterAction = 'include'): ?array {
168 168
     $body = [
169 169
       'topicName'         => $topic,
170 170
       'labelFilterAction' => $labelFilterAction
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     }
180 180
 
181 181
     list($code, $response) = (new GMailCURL(GMailCURL::POST))(
182
-      self::API . "$userId/watch",
182
+      self::API."$userId/watch",
183 183
       ["Authorization: Bearer $this->token"],
184 184
       $body
185 185
     );
Please login to merge, or discard this patch.