@@ -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] |
@@ -10,12 +10,12 @@ |
||
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); |
@@ -16,7 +16,9 @@ discard block |
||
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 |
||
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) { |
@@ -15,7 +15,9 @@ discard block |
||
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 |
||
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, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | private $clientSecret; |
15 | 15 | private $redirectUri = 'urn:ietf:wg:oauth:2.0:oob'; |
16 | 16 | |
17 | - function __construct($params=null) { |
|
17 | + function __construct($params = null) { |
|
18 | 18 | get_instance()->load->splint('francis94c/ci-gmail', '%curl'); |
19 | 19 | if ($params != null) $this->init($params); |
20 | 20 | } |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @param string $responseType Response type. 'code' by default. |
39 | 39 | * @return string Authorize URL |
40 | 40 | */ |
41 | - public function getAuthorizeUrl(string $scope, string $redirectUri=null, string $responseType='code', string $accessType='offline'):string { |
|
41 | + public function getAuthorizeUrl(string $scope, string $redirectUri = null, string $responseType = 'code', string $accessType = 'offline'):string { |
|
42 | 42 | $redirectUri = $redirectUri ?? $this->redirectUri; |
43 | 43 | if ($scope == null) throw new Exception("GMail scope cannot be null"); |
44 | - return self::AUTH_URL . build_url_query([ |
|
44 | + return self::AUTH_URL.build_url_query([ |
|
45 | 45 | 'client_id' => $this->clientId, |
46 | 46 | 'redirect_uri' => $redirectUri, |
47 | 47 | 'scope' => $scope, |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * @param string $code [description] |
55 | 55 | * @return [type] [description] |
56 | 56 | */ |
57 | - public function getToken(string $code, string $redirectUri=null):?array { |
|
57 | + public function getToken(string $code, string $redirectUri = null): ?array { |
|
58 | 58 | $redirectUri = $redirectUri ?? $this->redirectUri; |
59 | 59 | list($code, $result) = (new GMailCURL(GMailCURL::POST))( |
60 | - self::TOKEN_URL . build_url_query([ |
|
60 | + self::TOKEN_URL.build_url_query([ |
|
61 | 61 | 'code' => $code, |
62 | 62 | 'client_id' => $this->clientId, |
63 | 63 | 'client_secret' => $this->clientSecret, |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * [getClientId Get Client ID.] |
77 | 77 | * @return null|string Client ID. |
78 | 78 | */ |
79 | - public function getClientId():?string { |
|
79 | + public function getClientId(): ?string { |
|
80 | 80 | return $this->clientId; |
81 | 81 | } |
82 | 82 | } |
@@ -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); |
@@ -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)."&"; |