@@ -27,7 +27,7 @@ |
||
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 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private $allow_unsigned = false; |
38 | 38 | |
39 | - function __construct($params=null) { |
|
39 | + function __construct($params = null) { |
|
40 | 40 | if ($params != null) $this->init($params); |
41 | 41 | get_instance()->load->splint("francis94c/ci-jwt", "%base64"); |
42 | 42 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param [type] $secret [description] |
94 | 94 | * @return [type] [description] |
95 | 95 | */ |
96 | - public function sign(string $secret=null):?string { |
|
96 | + public function sign(string $secret = null): ?string { |
|
97 | 97 | // Checks. |
98 | - if (count($this->payload) == 0) return null; |
|
98 | + if (count($this->payload) == 0) return null; |
|
99 | 99 | // $key is $secret. |
100 | 100 | $key = $secret ?? $this->secret; |
101 | 101 | $this->header["alg"] = $this->header["alg"] ?? self::HS256; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * [token description] |
113 | 113 | * @return string [description] |
114 | 114 | */ |
115 | - public function token():?string { |
|
115 | + public function token(): ?string { |
|
116 | 116 | // Checks. |
117 | - if (count($this->payload) == 0) return null; |
|
117 | + if (count($this->payload) == 0) return null; |
|
118 | 118 | // Begin. |
119 | 119 | $this->header["alg"] = self::NONE; |
120 | 120 | return base64url_encode(json_encode($this->header)) . "." . base64url_encode(json_encode($this->payload)) . "."; |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | * @param string $secret [description] |
126 | 126 | * @return bool [description] |
127 | 127 | */ |
128 | - public function verify(string $jwt, string $secret=null):bool { |
|
128 | + public function verify(string $jwt, string $secret = null):bool { |
|
129 | 129 | if (substr_count($jwt, ".") != 2) return false; // Invalid JWT. |
130 | 130 | $key = $secret ?? $this->secret; |
131 | 131 | $parts = explode(".", $jwt); |
132 | - $header = json_decode(base64url_decode($parts[0]) ,true); |
|
132 | + $header = json_decode(base64url_decode($parts[0]), true); |
|
133 | 133 | if ($header == null) return false; |
134 | 134 | $alg = $header["alg"] ?? self::HS256; |
135 | - $payload = json_decode(base64url_decode($parts[1]) ,true); |
|
135 | + $payload = json_decode(base64url_decode($parts[1]), true); |
|
136 | 136 | if ($payload == null) return false; |
137 | 137 | if ($parts[2] == "") { |
138 | 138 | return $this->allow_unsigned; |
@@ -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 | * [$params Config Items.] |
26 | 26 | * |