Useless merge

This commit is contained in:
Chris 2023-04-09 02:44:23 +02:00
commit fabf160346
1 changed files with 14 additions and 13 deletions

View File

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