protected function JsonWebToken::internalSetClaim in JSON Web Token Authentication (JWT) 8.0
Same name and namespace in other branches
- 8 src/JsonWebToken/JsonWebToken.php \Drupal\jwt\JsonWebToken\JsonWebToken::internalSetClaim()
Traverses the JWT payload to the given claim and sets a value.
Parameters
object $payload: A reference to the JWT payload.
mixed $claim: Either a string or indexed array of strings representing the claim or nested claim to be set.
mixed $value: The value to set for the given claim.
1 call to JsonWebToken::internalSetClaim()
- JsonWebToken::setClaim in src/
JsonWebToken/ JsonWebToken.php - Add or update the given claim with the given value.
File
- src/
JsonWebToken/ JsonWebToken.php, line 101
Class
- JsonWebToken
- Class JsonWebToken.
Namespace
Drupal\jwt\JsonWebTokenCode
protected function internalSetClaim(&$payload, $claim, $value) {
$current_claim = is_array($claim) ? array_shift($claim) : $claim;
if (is_array($claim) && count($claim) > 0) {
if (!isset($payload->{$current_claim})) {
$payload->{$current_claim} = new \stdClass();
}
$this
->internalSetClaim($payload->{$current_claim}, $claim, $value);
}
else {
$payload->{$current_claim} = $value;
}
}