Lcobucci\JWT\Token::getClaim PHP Method

getClaim() public method

Returns the value of a token claim
public getClaim ( string $name, mixed $default = null ) : mixed
$name string
$default mixed
return mixed
    public function getClaim(string $name, $default = null)
    {
        if ($this->hasClaim($name)) {
            return $this->claims[$name]->getValue();
        }
        if ($default === null) {
            throw new OutOfBoundsException('Requested claim is not configured');
        }
        return $default;
    }

Usage Example

 public function loginByToken(Token $token)
 {
     $uid = $token->getClaim('uid');
     try {
         $this->user = $this->usersRepository->getById($uid);
     } catch (UserNotFoundException $e) {
         // do nothing here
     }
 }
All Usage Examples Of Lcobucci\JWT\Token::getClaim