| @@ -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 | } | 
| @@ -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 | * | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | */ | 
| 56 | 56 | private $algorithm; | 
| 57 | 57 | |
| 58 | -  function __construct($params=null) { | |
| 58 | +  function __construct($params = null) { | |
| 59 | 59 | if ($params != null) $this->init($params); | 
| 60 | 60 |      get_instance()->load->splint("francis94c/ci-jwt", "%base64"); | 
| 61 | 61 | } | 
| @@ -112,9 +112,9 @@ discard block | ||
| 112 | 112 | * @param [type] $secret [description] | 
| 113 | 113 | * @return [type] [description] | 
| 114 | 114 | */ | 
| 115 | -  public function sign(string $secret=null):?string { | |
| 115 | +  public function sign(string $secret = null): ?string { | |
| 116 | 116 | // Checks. | 
| 117 | - if (count($this->payload) == 0) return null; | |
| 117 | + if (count($this->payload) == 0) return null; | |
| 118 | 118 | // $key is $secret. | 
| 119 | 119 | $key = $secret ?? $this->secret; | 
| 120 | 120 | $this->header["alg"] = $this->header["alg"] ?? ($this->algorithm ?? self::HS512); | 
| @@ -135,9 +135,9 @@ discard block | ||
| 135 | 135 | * [token description] | 
| 136 | 136 | * @return string [description] | 
| 137 | 137 | */ | 
| 138 | -  public function token():?string { | |
| 138 | +  public function token(): ?string { | |
| 139 | 139 | // Checks. | 
| 140 | - if (count($this->payload) == 0) return null; | |
| 140 | + if (count($this->payload) == 0) return null; | |
| 141 | 141 | // Begin. | 
| 142 | 142 | $this->header["alg"] = self::NONE; | 
| 143 | 143 | if ($this->set_iat) $this->payload["iat"] = $this->payload["iat"] ?? time(); | 
| @@ -150,14 +150,14 @@ discard block | ||
| 150 | 150 | * @param string $secret [description] | 
| 151 | 151 | * @return bool [description] | 
| 152 | 152 | */ | 
| 153 | -  public function verify(string $jwt, string $secret=null):bool { | |
| 153 | +  public function verify(string $jwt, string $secret = null):bool { | |
| 154 | 154 | if (substr_count($jwt, ".") != 2) return false; // Invalid JWT. | 
| 155 | 155 | $key = $secret ?? $this->secret; | 
| 156 | 156 |      $parts = explode(".", $jwt); | 
| 157 | - $header = json_decode(base64url_decode($parts[0]) ,true); | |
| 157 | + $header = json_decode(base64url_decode($parts[0]), true); | |
| 158 | 158 | if ($header == null) return false; | 
| 159 | 159 | $alg = $header["alg"] ?? self::HS256; | 
| 160 | - $payload = json_decode(base64url_decode($parts[1]) ,true); | |
| 160 | + $payload = json_decode(base64url_decode($parts[1]), true); | |
| 161 | 161 | if ($payload == null) return false; | 
| 162 | 162 |      if ($parts[2] == "") { | 
| 163 | 163 | return $this->allow_unsigned; | 
| @@ -194,7 +194,7 @@ discard block | ||
| 194 | 194 | * @param string $jwt [description] | 
| 195 | 195 | * @return bool [description] | 
| 196 | 196 | */ | 
| 197 | -  public function expired(string $jwt=null):bool { | |
| 197 | +  public function expired(string $jwt = null):bool { | |
| 198 | 198 | $exp = $jwt == null ? ($this->payload["exp"] ?? time()) : $this->get_expired($jwt); | 
| 199 | 199 | return time() >= $exp; | 
| 200 | 200 | } | 
| @@ -216,7 +216,7 @@ discard block | ||
| 216 | 216 | */ | 
| 217 | 217 |    private function get_expired(string $jwt):int { | 
| 218 | 218 |      $parts = explode(".", $jwt); | 
| 219 | - return json_decode(base64url_decode($parts[1]) ,true)["exp"] ?? time(); | |
| 219 | + return json_decode(base64url_decode($parts[1]), true)["exp"] ?? time(); | |
| 220 | 220 | } | 
| 221 | 221 | /** | 
| 222 | 222 | * [sign_token Sign JWT] |