Lcobucci\JWT\Builder::sign PHP Method

sign() public method

Signs the data
public sign ( Lcobucci\JWT\Signer $signer, Lcobucci\JWT\Signer\Key $key ) : Builder
$signer Lcobucci\JWT\Signer
$key Lcobucci\JWT\Signer\Key
return Builder
    public function sign(Signer $signer, Key $key) : Builder
    {
        $signer->modifyHeader($this->headers);
        $this->signature = $signer->sign($this->getToken()->getPayload(), $key);
        return $this;
    }

Usage Example

 /**
  *
  * @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);
 }
All Usage Examples Of Lcobucci\JWT\Builder::sign