From f4cfd37745849c334e5bcd8bdb1c3b96b414258f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 5 Apr 2015 21:57:17 +0100 Subject: [PATCH] Added isExpired method --- src/Entities/Interfaces/TokenInterface.php | 6 ++++++ src/Entities/Traits/TokenEntityTrait.php | 9 +++++++++ 2 files changed, 15 insertions(+) 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