/**
  * @param array $claims
  * @return Jwt
  */
 public function encode($claims)
 {
     $builder = clone $this->builder;
     foreach ($claims as $claim => $value) {
         $builder->set($claim, $value);
     }
     $dateTime = $this->clock->getDateTime();
     $time = $dateTime->getTimestamp();
     $jwt = $builder->setIssuedAt($time)->setExpiration($time + $this->exp->toNative())->setNotBefore($time + $this->nbf->toNative())->sign($this->signer, $this->key)->getToken();
     return $jwt;
 }
 /**
  * Check if the provided timestamp is valid or not.
  *
  * @param  string  $oauthTimestamp A timestamp string.
  * @return boolean <code>true</code> if the timestamp is valid,
  *                  <code>false</code> otherwise.
  */
 protected function checkTimestamp($oauthTimestamp)
 {
     $currentTime = $this->clock->getDateTime()->getTimestamp();
     $maxTimestamp = $currentTime + $this->getAccessTokenInterval();
     $minTimestamp = $currentTime - $this->getAccessTokenInterval();
     return $oauthTimestamp > $minTimestamp && $oauthTimestamp < $maxTimestamp;
 }