From 4054502b4a181c2215ef79ee333ccbecded8edc3 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Thu, 1 Jun 2023 11:17:46 +0200 Subject: [PATCH] feat: return response as assoc array --- src/Reflect/Client.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Reflect/Client.php b/src/Reflect/Client.php index 41c835f..766e309 100644 --- a/src/Reflect/Client.php +++ b/src/Reflect/Client.php @@ -112,19 +112,22 @@ return $rx; } - // Create HTTP-like JSON with ["","","[payload]"] and return - // respone from endpoint as [""] + // Call a Reflect endpoint and return response as assoc array public function call(string $endpoint, Method|string $method = (__CLASS__)::HTTP_DEFAULT_METHOD, array $payload = null): array { // Resolve string to enum $method = $this::resolve_method($method); // Call endpoint over UNIX socket if ($this->_con === Connection::AF_UNIX) { - return json_decode($this->socket_txn(json_encode([ - $endpoint, - $method->value, - $payload - ]))); + // Return response as assoc array + return json_decode($this->socket_txn( + // Send request as stringified JSON + json_encode([ + $endpoint, + $method->value, + $payload + ]) + ), true); } // Call endpoint over HTTP