public function createToken($payload, $secret = null, $algo = null)
    {
        $algo = $algo ?: $this->algorithm();
        $secret = $secret ?: $this->secret();

        if($payload instanceof JwtPayloadInterface) {
            $payload = $payload->getPayload();
        }

        $newToken = $this->jwt->createToken($payload, $secret, $algo);

        $token = clone $this;
        $token->setToken($newToken);

        return $token;
    }
public function createToken($payload, $secret = null, $algo = null)
    {
        $algo = $algo ?: $this->algorithm();
        $secret = $secret ?: $this->secret();

        if($payload instanceof JwtPayloadInterface) {
            $payload = $payload->getPayload();
        }

        $newToken = $this->jwt->createToken($payload, $secret, $algo);

        $token = clone $this;
        $token->setToken($newToken);

        return $token;
    }
public function createToken ( $ payload , $ secret = null , $ algo = null ) { $ algo = $ algo ? : $ this -> algorithm ( ) ; $ secret = $ secret ? : $ this -> secret ( ) ; if ( $ payload instanceof JwtPayloadInterface ) { $ payload = $ payload -> getPayload ( ) ; } $ newToken = $ this -> jwt -> createToken ( $ payload , $ secret , $ algo ) ; $ token = clone $ this ; $ token -> setToken ( $ newToken ) ; return $ token ; }
Create a new token with the provided payload

The default algorithm used is HS256. To set a custom one, set
the env variable JWT_ALGO.

@todo Support for enforcing required claims in payload as well as defaults

@param JwtPayloadInterface|array $payload
@param string|null               $secret
@param string|null               $algo

@return JwtToken
Create a new token with the provided payload