public function verifyRegistration(TokenEntity $token)
    {
        if ($token->isNew()) {
            throw new OutOfBoundsException('NOT_FOUND', self::TOKEN_NOT_FOUND);
        }

        if ((int) $token->getTokenTypeId() !== TokenEntity::TYPE_VERIFY_REGISTRATION) {
            throw new OutOfBoundsException('NOT_FOUND', self::INCORRECT_TOKEN_TYPE);
        }

        if ($token->getExpires() < time()) {
            throw new OutOfBoundsException('EXPIRED', self::TOKEN_EXPIRED);
        }

        $user = $this->findById($token->getUserId());

        // Token looks good; verify user and delete the token
        $user->setVerified(true);

        $this->userMapper->persist($user);

        $this->tokenMapper->delete($token);

        return $user;
    }