Passed
Push — master ( bf1c32...1d6896 )
by Francis
01:20
created
libraries/GMailUtil.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 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=[], mixed $body=null):array {
18
+  function __invoke(string $url, array $header = [], mixed $body = null):array {
19 19
     if ($body != null) $body = json_encode($body);
20 20
 
21 21
     $ch = curl_init($url);
Please login to merge, or discard this 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
 
@@ -26,7 +28,9 @@  discard block
 block discarded – undo
26 28
     // Header.
27 29
     $header[] = 'Content-Type: application/json';
28 30
     $header[] = 'User-Agent: '.$this->userAgent;
29
-    if ($body != null) $header[] = 'Content-Length: '.strlen($body);
31
+    if ($body != null) {
32
+      $header[] = 'Content-Length: '.strlen($body);
33
+    }
30 34
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
31 35
     // Request Method and Body.
32 36
     if ($this->method == self::POST) {
Please login to merge, or discard this patch.
libraries/GMail.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   private $clientSecret;
14 14
   private $redirectUri = 'urn:ietf:wg:oauth:2.0:oob';
15 15
 
16
-  function __construct($params=null) {
16
+  function __construct($params = null) {
17 17
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
18 18
     if ($params != null) $this->init($params);
19 19
   }
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
    * @param  string $responseType Response type. 'code' by default.
38 38
    * @return string               Authorize URL
39 39
    */
40
-  public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline'):string {
40
+  public function getAuthorizeUrl(string $scope, string $redirectUri = null, string $responseType = 'code', string $accessType = 'offline'):string {
41 41
     $redirectUri = $redirectUri ?? $this->redirectUri;
42 42
     if ($scope == null) throw new Exception("GMail scope cannot be null");
43
-    return self::AUTH_URL . build_url_query([
43
+    return self::AUTH_URL.build_url_query([
44 44
       'client_id'     => $this->clientId,
45 45
       'redirect_uri'  => $redirectUri,
46 46
       'scope'         => $scope,
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
    * @param  string $code [description]
54 54
    * @return [type]       [description]
55 55
    */
56
-  public function getToken(string $code, string $redirectUri=null):?array {
56
+  public function getToken(string $code, string $redirectUri = null): ?array {
57 57
     $redirectUri = $redirectUri ?? $this->redirectUri;
58 58
     $result = (new GMailCURL(GMailCURL::POST))(
59
-      self::TOKEN_URL . build_url_query([
59
+      self::TOKEN_URL.build_url_query([
60 60
         'code'          => $code,
61 61
         'client_id'     => $this->clientId,
62 62
         'client_secret' => $this->clientSecret,
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
    * [getClientId Get Client ID.]
69 69
    * @return null|string Client ID.
70 70
    */
71
-  public function getClientId():?string {
71
+  public function getClientId(): ?string {
72 72
     return $this->clientId;
73 73
   }
74 74
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
   function __construct($params=null) {
17 17
     get_instance()->load->splint('francis94c/ci-gmail', '%curl');
18
-    if ($params != null) $this->init($params);
18
+    if ($params != null) {
19
+      $this->init($params);
20
+    }
19 21
   }
20 22
 
21 23
   /**
@@ -39,7 +41,9 @@  discard block
 block discarded – undo
39 41
    */
40 42
   public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline'):string {
41 43
     $redirectUri = $redirectUri ?? $this->redirectUri;
42
-    if ($scope == null) throw new Exception("GMail scope cannot be null");
44
+    if ($scope == null) {
45
+      throw new Exception("GMail scope cannot be null");
46
+    }
43 47
     return self::AUTH_URL . build_url_query([
44 48
       'client_id'     => $this->clientId,
45 49
       'redirect_uri'  => $redirectUri,
Please login to merge, or discard this patch.
helpers/curl_helper.php 2 patches
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.
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.