class Token in Janrain Registration 8
The token.
Hierarchy
- class \Drupal\janrain_capture\Authentication\Token
Expanded class hierarchy of Token
File
- src/
Authentication/ Token.php, line 8
Namespace
Drupal\janrain_capture\AuthenticationView source
class Token {
/**
* The token itself.
*
* @var string
*/
protected $token;
/**
* The expiration of a token.
*
* @var \DateTime|null
*/
protected $expiration;
/**
* The token's life in seconds.
*
* @var int
*/
protected $expiresIn = 0;
/**
* {@inheritdoc}
*/
public function __construct(string $token) {
$this->token = $token;
}
/**
* {@inheritdoc}
*/
public function __toString() : string {
return $this
->getToken();
}
/**
* {@inheritdoc}
*/
public function getToken() : string {
return $this->token;
}
/**
* {@inheritdoc}
*/
public function setExpiration(int $expiration) : void {
$this->expiresIn = $expiration;
$this->expiration = new \DateTime();
$this->expiration
->setTimestamp(\Drupal::time()
->getRequestTime() + $expiration);
}
/**
* {@inheritdoc}
*/
public function getExpiresIn() : int {
return $this->expiresIn;
}
/**
* {@inheritdoc}
*/
public function getExpiration() : ?\DateTime {
return $this->expiration;
}
/**
* {@inheritdoc}
*/
public function isExpired() : bool {
$expiration = $this
->getExpiration();
// No expiration - token is permanent.
if ($expiration === NULL) {
return FALSE;
}
return $expiration
->getTimestamp() < \Drupal::time()
->getRequestTime();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Token:: |
protected | property | The expiration of a token. | |
Token:: |
protected | property | The token's life in seconds. | |
Token:: |
protected | property | The token itself. | |
Token:: |
public | function | 1 | |
Token:: |
public | function | ||
Token:: |
public | function | ||
Token:: |
public | function | ||
Token:: |
public | function | ||
Token:: |
public | function | 1 | |
Token:: |
public | function |