diff --git a/src/Entities/Interfaces/TokenInterface.php b/src/Entities/Interfaces/TokenInterface.php index 22f37d05..89e223ac 100644 --- a/src/Entities/Interfaces/TokenInterface.php +++ b/src/Entities/Interfaces/TokenInterface.php @@ -76,4 +76,10 @@ interface TokenInterface * @return ScopeEntityInterface[] */ public function getScopes(); + + /** + * Has the token expired? + * @return bool + */ + public function isExpired(); } diff --git a/src/Entities/Traits/TokenEntityTrait.php b/src/Entities/Traits/TokenEntityTrait.php index bcd756bf..92503973 100644 --- a/src/Entities/Traits/TokenEntityTrait.php +++ b/src/Entities/Traits/TokenEntityTrait.php @@ -123,4 +123,13 @@ trait TokenEntityTrait { $this->client = $client; } + + /** + * Has the token expired? + * @return bool + */ + public function isExpired() + { + return (new \DateTime()) > $this->getExpiryDateTime(); + } } \ No newline at end of file