diff options
Diffstat (limited to 'Core/Authentication')
-rw-r--r-- | Core/Authentication/Token/Token.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Core/Authentication/Token/Token.php b/Core/Authentication/Token/Token.php index e4e5d55..1efa5d6 100644 --- a/Core/Authentication/Token/Token.php +++ b/Core/Authentication/Token/Token.php @@ -85,13 +85,13 @@ abstract class Token implements TokenInterface */ public function __toString() { - if (!is_object($this->user)) { - return (string) $this->user; - } elseif ($this->user instanceof AccountInterface) { + if (is_string($this->user)) { + return $this->user; + } else if ($this->user instanceof AccountInterface) { return $this->user->getUsername(); - } else { - return 'n/a'; } + + return (string) $this->user; } /** @@ -141,7 +141,7 @@ abstract class Token implements TokenInterface if (!is_string($user) && !is_object($user)) { throw new \InvalidArgumentException('$user must be an object, or a primitive string.'); - } else if (is_object($user) && !method_exists($user, '__toString')) { + } else if (is_object($user) && !$user instanceof AccountInterface && !method_exists($user, '__toString')) { throw new \InvalidArgumentException('If $user is an object, it must implement __toString().'); } |