Added docblocks
This commit is contained in:
parent
5c422226fd
commit
c5dd773026
@ -72,11 +72,25 @@ class JWTToken
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the expiry is not in the past.
|
||||||
|
*
|
||||||
|
* NOTE: This function will return true if the expiry header is missing, and
|
||||||
|
* it will not validate any claims. For actual verification of a token matching
|
||||||
|
* issuers, audience or other claims, see Validator\JWTValidator.
|
||||||
|
*
|
||||||
|
* @return bool True if the token expiry timestamp is missing or in the future
|
||||||
|
*/
|
||||||
public function isValid(): bool
|
public function isValid(): bool
|
||||||
{
|
{
|
||||||
return $this->valid;
|
return $this->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the token was generated as opposed to parsed.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isGenerated(): bool
|
public function isGenerated(): bool
|
||||||
{
|
{
|
||||||
return $this->generated;
|
return $this->generated;
|
||||||
@ -90,16 +104,43 @@ class JWTToken
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a claim to a token. Throws an exception if the claim already exists.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the claim
|
||||||
|
* @param mixed $value Claim value
|
||||||
|
* @throws \NoccyLabs\SimpleJWT\Collection\PropertyException if the claim already exists.
|
||||||
|
*/
|
||||||
public function addClaim(string $name, $value)
|
public function addClaim(string $name, $value)
|
||||||
{
|
{
|
||||||
$this->claims->add($name, $value);
|
$this->claims->add($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a claim to a token. If the claim already exists it will be updated with
|
||||||
|
* the provided value.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the claim
|
||||||
|
* @param mixed $value Claim value
|
||||||
|
*/
|
||||||
public function setClaim(string $name, $value)
|
public function setClaim(string $name, $value)
|
||||||
{
|
{
|
||||||
$this->claims->set($name, $value);
|
$this->claims->set($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the time of expiry for the token.
|
||||||
|
*
|
||||||
|
* The expiry can be supplied as:
|
||||||
|
* - \DateTime instance
|
||||||
|
* - Unixtime as an integer
|
||||||
|
* - A string represening the expiry time
|
||||||
|
* - A period followed by a letter (m,h,d,w)
|
||||||
|
* - null, to unset the expiry
|
||||||
|
*
|
||||||
|
* @param string|int|\DateTime $expiry
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function setExpiry($expiry)
|
public function setExpiry($expiry)
|
||||||
{
|
{
|
||||||
if ($expiry instanceof \DateTime) {
|
if ($expiry instanceof \DateTime) {
|
||||||
|
Loading…
Reference in New Issue
Block a user