isValidNow
Learn how to check whether the token is currently valid.
This method reports whether the token is within its validity period. The token is valid when the current time is at or after the issue time and before the expiration time.
Signature
This method has the following signature:
public function isValidNow(?int $now = null): boolThis method returns true when the token is currently within its validity period, and false otherwise.
Example
Here is a basic example of how to use this method:
<?phpuse Croct\Plug\Croct;
$croct = Croct::fromDotenv();$token = $croct->getUserToken();
if ($token->isValidNow()) { // The token is within its validity period.}Parameters
The following list describes the supported parameters:
- now(optional)int|null
The reference time to check against, as a Unix timestamp in seconds. The default is null, which uses the current time.
Default:null