Psecio\Jwt\Jwt::custom PHP Method

custom() public method

Allow for the insertion of multiple custom values at once
public custom ( string | array $value, string $name = null ) : Jwt
$value string | array Either a string for a single claim or array for multiple
$name string Name of claim to use if string given for "name" [optional]
return Jwt instance
    public function custom($value, $name = null)
    {
        $value = !is_array($value) ? array($name => $value) : $value;
        foreach ($value as $type => $value) {
            $claim = new \Psecio\Jwt\Claim\Custom($value, $type);
            $this->addClaim($claim);
        }
        return $this;
    }

Usage Example

 public function generateAuthToken($user)
 {
     $header = new JwtHeader($this->getAuthKey());
     $jwt = new Jwt($header);
     $jwt->custom($this->getAuthOptions());
     $jwt->issuer($this->getForestUri())->issuedAt(time())->notBefore(time() + 60)->expireTime(time() + 3600)->jwtId($user->id);
     return $jwt->encode();
 }