Useless merge

This commit is contained in:
Chris 2023-04-09 02:44:23 +02:00
commit fabf160346

View File

@ -47,8 +47,8 @@ or a `JWTPlaintextKey` and pass it to the `JWTToken` constructor:
$tok->setExpiry("1h"); $tok->setExpiry("1h");
$tok->claims->add("some/claim/MaxItems", 8); $tok->claims->add("some/claim/MaxItems", 8);
$str = $tok->getSignedToken(); $str = $tok->getSignedToken();
```
### Parsing tokens ### Parsing tokens
@ -56,22 +56,23 @@ Parsing is done by passing the raw token as the 2nd parameter
use NoccyLabs\SimpleJWT\JWTToken; use NoccyLabs\SimpleJWT\JWTToken;
$str = "...received token..."; $str = "...received token...";
$tok = new JWTToken($key, $str); $tok = new JWTToken($key, $str);
if (!$tok->isValid()) { if (!$tok->isValid()) {
// This check works, but using the validator might be better // This check works, but using the validator might be better
} }
// Using ->has() follwed by ->get() is one way // Using ->has() follwed by ->get() is one way
if ($tok->claims->has("some/claim/MaxItems")) { if ($tok->claims->has("some/claim/MaxItems")) {
// The claim exists, we can get the value (if any) // The claim exists, we can get the value (if any)
$val = $tok->claims->get("some/claim/MaxItems"); $val = $tok->claims->get("some/claim/MaxItems");
} }
// You can also use valueOf() to return a default value if needed // You can also use valueOf() to return a default value if needed
$val = $tok->claims->valueOf("some/claim/MaxItems", 64); $val = $tok->claims->valueOf("some/claim/MaxItems", 64);
```
### Validating tokens ### Validating tokens