public function create()
    {
        $this->validate();

        $claims        = $this->processOptions();
        $claims['d']   = $this->data;
        $claims['v']   = 0;
        $claims['iat'] = time();

        try {
            $token = JWT::encode($claims, $this->secret, 'HS256');
        } catch (\Exception $e) {
            throw new TokenException($e->getMessage(), null, $e);
        }

        if (($tokenSize = mb_strlen($token, '8bit')) > static::MAX_TOKEN_SIZE) {
            throw new TokenException(
                sprintf('The generated token is larger than %d bytes (%d)', static::MAX_TOKEN_SIZE, $tokenSize)
            );
        }

        return $token;
    }
public function create()
    {
        $this->validate();

        $claims        = $this->processOptions();
        $claims['d']   = $this->data;
        $claims['v']   = 0;
        $claims['iat'] = time();

        try {
            $token = JWT::encode($claims, $this->secret, 'HS256');
        } catch (\Exception $e) {
            throw new TokenException($e->getMessage(), null, $e);
        }

        if (($tokenSize = mb_strlen($token, '8bit')) > static::MAX_TOKEN_SIZE) {
            throw new TokenException(
                sprintf('The generated token is larger than %d bytes (%d)', static::MAX_TOKEN_SIZE, $tokenSize)
            );
        }

        return $token;
    }
public function create ( ) { $ this -> validate ( ) ; $ claims = $ this -> processOptions ( ) ; $ claims [ 'd' ] = $ this -> data ; $ claims [ 'v' ] = 0 ; $ claims [ 'iat' ] = time ( ) ; try { $ token = JWT :: encode ( $ claims , $ this -> secret , 'HS256' ) ; } catch ( \ Exception $ e ) { throw new TokenException ( $ e -> getMessage ( ) , null , $ e ) ; } if ( ( $ tokenSize = mb_strlen ( $ token , '8bit' ) ) > static :: MAX_TOKEN_SIZE ) { throw new TokenException ( sprintf ( 'The generated token is larger than %d bytes (%d)' , static :: MAX_TOKEN_SIZE , $ tokenSize ) ) ; } return $ token ; }
Creates the token.

@throws TokenException If the token couldn't be generated or is invalid.

@return string The JWT token.
Creates the token .