From 11664e6d37daf11b8940e370713f51b5972249a3 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Fri, 9 May 2014 08:16:02 +0100 Subject: [PATCH] Added ability to cast token as a string --- src/Entity/AbstractTokenEntity.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Entity/AbstractTokenEntity.php b/src/Entity/AbstractTokenEntity.php index 94fd82a9..45140ad8 100644 --- a/src/Entity/AbstractTokenEntity.php +++ b/src/Entity/AbstractTokenEntity.php @@ -147,6 +147,19 @@ abstract class AbstractTokenEntity return $scopes; } + /** + * Returns the token as a string if the object is cast as a string + * @return string + */ + public function __toString() + { + if (is_null($this->token)) { + throw new \BadMethodCallException('Token is null'); + } + + return $this->token; + } + /** * Expire the token * @return void