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