You are here

protected function JsonWebToken::internalGetClaim in JSON Web Token Authentication (JWT) 8

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

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

Return value

mixed The claims value.

1 call to JsonWebToken::internalGetClaim()
JsonWebToken::getClaim in src/JsonWebToken/JsonWebToken.php
Retrieve a claim from the JWT payload.

File

src/JsonWebToken/JsonWebToken.php, line 75

Class

JsonWebToken
Class JsonWebToken.

Namespace

Drupal\jwt\JsonWebToken

Code

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