From 61daa1569f82e177e7989f403c49e9c0033a27f5 Mon Sep 17 00:00:00 2001 From: freekmurze Date: Fri, 28 Jun 2024 07:58:30 +0000 Subject: [PATCH] Fix styling --- src/SslCertificate.php | 9 ++++++--- tests/SslCertificateSerializationTest.php | 13 ++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/SslCertificate.php b/src/SslCertificate.php index d4a2aaf..8218a85 100644 --- a/src/SslCertificate.php +++ b/src/SslCertificate.php @@ -334,13 +334,16 @@ public function isPreCertificate(): bool return true; } - public function __serialize(): array { + public function __serialize(): array + { $data = $this->toArray(); $data['publicKeyDetail'] = base64_encode(serialize($data['publicKeyDetail'])); + return $data; } - - public function __unserialize($data): void { + + public function __unserialize($data): void + { $data['publicKeyDetail'] = unserialize(base64_decode($data['publicKeyDetail'])); $this->__construct(...$data); } diff --git a/tests/SslCertificateSerializationTest.php b/tests/SslCertificateSerializationTest.php index f9fe492..c82dba1 100644 --- a/tests/SslCertificateSerializationTest.php +++ b/tests/SslCertificateSerializationTest.php @@ -1,28 +1,27 @@ toArray() ); - + expect(json_last_error_msg())->toEqual('Malformed UTF-8 characters, possibly incorrectly encoded'); }); -it('can json encode serialized certificate', function() { +it('can json encode serialized certificate', function () { $json = json_encode( serialize(SslCertificate::createFromFile(__DIR__ . '/stubs/spatieCertificate.pem')) ); - + expect(json_last_error_msg())->toEqual('No error'); }); -it('can unserialize serialized certificate', function() { +it('can unserialize serialized certificate', function () { $serialized = serialize(SslCertificate::createFromFile(__DIR__ . '/stubs/spatieCertificate.pem')); $unserialized = unserialize($serialized); expect($unserialized->getDomain())->toEqual("analytics.spatie.be"); -}); \ No newline at end of file +});