/**
*
* @param string $secret
* @param int $accountId
* @param int $arkonUserId
* @param \DateTimeZone $timeZone
*/
public function __construct($secret, $accountId, $arkonUserId, \DateTimeZone $timeZone = null)
{
$signer = new Sha();
$this->token = (new Builder())->set(self::CLAIM_ACCOUNT_ID, $accountId);
if ($arkonUserId) {
$this->token->set(self::CLAIM_ARKON_USER_ID, $arkonUserId);
}
if (!is_null($timeZone)) {
$this->token->set(self::CLAIM_TIME_ZONE, $timeZone->getName());
}
$date = new \DateTime(null, new \DateTimeZone(self::JWT_TIME_ZONE));
$this->token->set(self::CLAIM_ISSUED_AT_TIME, $date->format(self::JWT_DATE_FORMAT));
$this->token->sign($signer, $secret);
}