You are here

protected function JsonWebToken::internalUnsetClaim in JSON Web Token Authentication (JWT) 8.0

Same name and namespace in other branches
  1. 8 src/JsonWebToken/JsonWebToken.php \Drupal\jwt\JsonWebToken\JsonWebToken::internalUnsetClaim()

Traverses the JWT payload to the given claim and unset its 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.

1 call to JsonWebToken::internalUnsetClaim()
JsonWebToken::unsetClaim in src/JsonWebToken/JsonWebToken.php
Remove a claim from the JWT payload.

File

src/JsonWebToken/JsonWebToken.php, line 125

Class

JsonWebToken
Class JsonWebToken.

Namespace

Drupal\jwt\JsonWebToken

Code

protected function internalUnsetClaim(&$payload, $claim) {
  $current_claim = is_array($claim) ? array_shift($claim) : $claim;
  if (!isset($payload->{$current_claim})) {
    return;
  }
  if (is_array($claim) && count($claim) > 0) {
    $this
      ->internalUnsetClaim($payload->{$current_claim}, $claim);
  }
  else {
    unset($payload->{$current_claim});
  }
}