Token.php in Janrain Registration 8
File
src/Authentication/Token.php
View source
<?php
namespace Drupal\janrain_capture\Authentication;
class Token {
protected $token;
protected $expiration;
protected $expiresIn = 0;
public function __construct(string $token) {
$this->token = $token;
}
public function __toString() : string {
return $this
->getToken();
}
public function getToken() : string {
return $this->token;
}
public function setExpiration(int $expiration) : void {
$this->expiresIn = $expiration;
$this->expiration = new \DateTime();
$this->expiration
->setTimestamp(\Drupal::time()
->getRequestTime() + $expiration);
}
public function getExpiresIn() : int {
return $this->expiresIn;
}
public function getExpiration() : ?\DateTime {
return $this->expiration;
}
public function isExpired() : bool {
$expiration = $this
->getExpiration();
if ($expiration === NULL) {
return FALSE;
}
return $expiration
->getTimestamp() < \Drupal::time()
->getRequestTime();
}
}