From 4052eedd8bc8c67c33e55d566633bf77cf69e158 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Mon, 20 Dec 2021 17:01:12 -0500 Subject: [PATCH] Support pretty-printing for SignedMessage --- lib/Protocol/SignedMessage.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Protocol/SignedMessage.php b/lib/Protocol/SignedMessage.php index d3c4b1d..510af58 100644 --- a/lib/Protocol/SignedMessage.php +++ b/lib/Protocol/SignedMessage.php @@ -148,11 +148,13 @@ public function setMeta($key, $value) } /** + * @param bool $pretty * @return string * @throws SodiumException */ - public function toString() + public function toString($pretty = false) { + $code = $pretty ? JSON_PRETTY_PRINT : 0; return (string) json_encode(array( 'signature' => sodium_bin2base64( Util::rawBinary($this->message->getSignature(), 64), @@ -161,7 +163,7 @@ public function toString() 'message' => $this->message->getContents(), 'provider' => $this->provider, 'public-key' => $this->publicKey - )); + ), $code); } /**