Jose\Factory\JWSFactory::createJWS PHP Method

createJWS() public static method

public static createJWS ( $payload, $is_payload_detached = false )
    public static function createJWS($payload, $is_payload_detached = false)
    {
        $jws = new JWS();
        $jws = $jws->withPayload($payload);
        if (true === $is_payload_detached) {
            $jws = $jws->withDetachedPayload();
        } else {
            $jws = $jws->withAttachedPayload();
        }
        return $jws;
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function sign($payload, array $signature_protected_headers, Object\JWKInterface $signature_key)
 {
     $jws = Factory\JWSFactory::createJWS($payload);
     $jws = $jws->addSignatureInformation($signature_key, $signature_protected_headers);
     $this->signer->sign($jws);
     return $jws->toCompactJSON(0);
 }