src/Token.php
public static function customPayload(array $payload, string $secret): string
    {
        $builder = self::builder();

        foreach ($payload as $key => $value) {
            if (is_int($key)) {
                throw new ValidateException('Invalid payload claim.', 8);
            }

            $builder->setPayloadClaim($key, $value);
        }

        return $builder->setSecret($secret)
            ->build()
            ->getToken();
    }
public static function customPayload(array $payload, string $secret): string
    {
        $builder = self::builder();

        foreach ($payload as $key => $value) {
            if (is_int($key)) {
                throw new ValidateException('Invalid payload claim.', 8);
            }

            $builder->setPayloadClaim($key, $value);
        }

        return $builder->setSecret($secret)
            ->build()
            ->getToken();
    }
public static function customPayload ( array $ payload , string $ secret ) : string { $ builder = self :: builder ( ) ; foreach ( $ payload as $ key => $ value ) { if ( is_int ( $ key ) ) { throw new ValidateException ( 'Invalid payload claim.' , 8 ) ; } $ builder -> setPayloadClaim ( $ key , $ value ) ; } return $ builder -> setSecret ( $ secret ) -> build ( ) -> getToken ( ) ; }
Create a JSON Web Token with a custom payload built from a key
value array.

@param array $payload

@return string
Create a JSON Web Token with a custom payload built from a key value array .