Passed
Push — master ( 17150d...65b777 )
by Francis
01:18
created
helpers/base64_helper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
    *
28 28
    * @return string|bool          Decoded String.
29 29
    */
30
-  function base64url_decode(string $data, bool $strict=false) {
30
+  function base64url_decode(string $data, bool $strict = false) {
31 31
     $b64 = strtr($data, '-_', '+/');
32 32
     return base64_decode($b64, $strict);
33 33
   }
Please login to merge, or discard this patch.
phpunit/JWTTest.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
      * [$params Config Items.]
26 26
      *
Please login to merge, or discard this patch.
libraries/JWT.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
    * @date  2020-03-28
70 70
    * @param [type] $params Config array.
71 71
    */
72
-  public function __construct(?array $params=null)
72
+  public function __construct(?array $params = null)
73 73
   {
74 74
     if ($params != null) $this->init($params);
75 75
     get_instance()->load->splint("francis94c/ci-jwt", "%base64");
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
    *                         if specified, or the header array if no key is
111 111
    *                         specified. Method chaining is supported.
112 112
    */
113
-  public function header(?string $key=null, $value=null)
113
+  public function header(?string $key = null, $value = null)
114 114
   {
115 115
     if (!$key) return $this->header;
116 116
     if ($value === null) return $this->header[$key];
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
    * @return mixed|null Value of $key if $value == null, payload array if $key
137 137
    *                    == null. Method chaining supported.
138 138
    */
139
-  public function payload(?string $key=null, $value=null)
139
+  public function payload(?string $key = null, $value = null)
140 140
   {
141 141
     if (!$key) return $this->payload;
142 142
     if ($value === null) return $this->payload[$key];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    * @return mixed|none      Value of the 'iss' claim, if the $iss argument wasn't
165 165
    *                         supplied. Otherwise, null.
166 166
    */
167
-  public function iss(string $iss=null)
167
+  public function iss(string $iss = null)
168 168
   {
169 169
     if ($iss === null) return $this->payload['iss'];
170 170
     $this->payload['iss'] = $iss;
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
    * @param  [type] $secret [description]
198 198
    * @return [type]         [description]
199 199
    */
200
-  public function sign(string $secret=null):?string {
200
+  public function sign(string $secret = null): ?string {
201 201
     // Checks.
202
-    if  (count($this->payload) == 0) return null;
202
+    if (count($this->payload) == 0) return null;
203 203
     // $key is $secret.
204 204
     $key = $secret ?? $this->secret;
205 205
     $this->header["alg"] = $this->header["alg"] ?? ($this->algorithm ?? self::HS512);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
    * [token description]
222 222
    * @return string [description]
223 223
    */
224
-  public function token():?string
224
+  public function token(): ?string
225 225
   {
226 226
     // Checks.
227
-    if  (count($this->payload) == 0) return null;
227
+    if (count($this->payload) == 0) return null;
228 228
     // Begin.
229 229
     $this->header["alg"] = self::NONE;
230 230
     if ($this->set_iat) $this->payload["iat"] = $this->payload["iat"] ?? time();
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
    * @param  string $secret [description]
239 239
    * @return bool           [description]
240 240
    */
241
-  public function verify(string $jwt, string $secret=null):bool {
241
+  public function verify(string $jwt, string $secret = null):bool {
242 242
     if (substr_count($jwt, ".") != 2) return false; // Invalid JWT.
243 243
     $key = $secret ?? $this->secret;
244 244
     $parts = explode(".", $jwt);
245
-    $header = json_decode(base64url_decode($parts[0]) ,true);
245
+    $header = json_decode(base64url_decode($parts[0]), true);
246 246
     if ($header == null) return false;
247 247
     $alg = $this->algorithm ?? $header["alg"] ?? self::HS256;
248
-    $payload = json_decode(base64url_decode($parts[1]) ,true);
248
+    $payload = json_decode(base64url_decode($parts[1]), true);
249 249
     if ($payload == null) return false;
250 250
     if ($parts[2] == "") {
251 251
       return $this->allow_unsigned;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
    * @param  string $jwt [description]
286 286
    * @return bool        [description]
287 287
    */
288
-  public function expired(string $jwt=null):bool {
288
+  public function expired(string $jwt = null):bool {
289 289
     $exp = $jwt == null ? ($this->payload["exp"] ?? time() + 4) : $this->get_expired($jwt);
290 290
     return time() >= $exp;
291 291
   }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   private function get_expired(string $jwt):int
311 311
   {
312 312
     $parts = explode(".", $jwt);
313
-    return json_decode(base64url_decode($parts[1]) ,true)["exp"] ?? time() + 4;
313
+    return json_decode(base64url_decode($parts[1]), true)["exp"] ?? time() + 4;
314 314
   }
315 315
 
316 316
   /**
Please login to merge, or discard this patch.