From d8b5c070bdf224ad4ab608c5fa1304667da89d19 Mon Sep 17 00:00:00 2001 From: aB0t Date: Sat, 27 Jan 2024 09:09:12 +0200 Subject: [PATCH] update 2024-01-27 --- .../code.php | 21 ++++++++++--------- .../code.power | 19 +++++++++-------- .../settings.json | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/c464393e-7606-406e-8463-a86774590966/code.php b/src/c464393e-7606-406e-8463-a86774590966/code.php index b07d31d..826f806 100644 --- a/src/c464393e-7606-406e-8463-a86774590966/code.php +++ b/src/c464393e-7606-406e-8463-a86774590966/code.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Openai\Utilities; -use Joomla\CMS\Http\Response as JoomlaResponse; +use Joomla\Http\Response as JoomlaResponse; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\StringHelper; @@ -36,7 +36,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + public function get($response, int $expectedCode = 200, $default = null) { // Validate the response code. if ($response->code != $expectedCode) @@ -62,7 +62,7 @@ final class Response * @since 3.2.0 * @throws \DomainException **/ - public function get_(JoomlaResponse $response, array $validate = [200 => null]) + public function get_($response, array $validate = [200 => null]) { // Validate the response code. if (!isset($validate[$response->code])) @@ -87,17 +87,18 @@ final class Response * @return mixed * @since 3.2.0 **/ - protected function body(JoomlaResponse $response, $default = null) + protected function body($response, $default = null) { - // check that we have a body and that its JSON - if (isset($response->body) && StringHelper::check($response->body)) + $body = $response->body ?? null; + // check that we have a body + if (StringHelper::check($body)) { - if (JsonHelper::check($response->body)) + if (JsonHelper::check($body)) { - return json_decode((string) $response->body); + $body = json_decode((string) $body); } - return $response->body; + return $body; } return $default; @@ -111,7 +112,7 @@ final class Response * @return string * @since 3.2.0 **/ - protected function error(JoomlaResponse $response): string + protected function error($response): string { // do we have a json string if (isset($response->body) && JsonHelper::check($response->body)) diff --git a/src/c464393e-7606-406e-8463-a86774590966/code.power b/src/c464393e-7606-406e-8463-a86774590966/code.power index 417bedc..3b0d369 100644 --- a/src/c464393e-7606-406e-8463-a86774590966/code.power +++ b/src/c464393e-7606-406e-8463-a86774590966/code.power @@ -10,7 +10,7 @@ * @since 3.2.0 * @throws \DomainException **/ - public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + public function get($response, int $expectedCode = 200, $default = null) { // Validate the response code. if ($response->code != $expectedCode) @@ -36,7 +36,7 @@ * @since 3.2.0 * @throws \DomainException **/ - public function get_(JoomlaResponse $response, array $validate = [200 => null]) + public function get_($response, array $validate = [200 => null]) { // Validate the response code. if (!isset($validate[$response->code])) @@ -61,17 +61,18 @@ * @return mixed * @since 3.2.0 **/ - protected function body(JoomlaResponse $response, $default = null) + protected function body($response, $default = null) { - // check that we have a body and that its JSON - if (isset($response->body) && StringHelper::check($response->body)) + $body = $response->body ?? null; + // check that we have a body + if (StringHelper::check($body)) { - if (JsonHelper::check($response->body)) + if (JsonHelper::check($body)) { - return json_decode((string) $response->body); + $body = json_decode((string) $body); } - return $response->body; + return $body; } return $default; @@ -85,7 +86,7 @@ * @return string * @since 3.2.0 **/ - protected function error(JoomlaResponse $response): string + protected function error($response): string { // do we have a json string if (isset($response->body) && JsonHelper::check($response->body)) diff --git a/src/c464393e-7606-406e-8463-a86774590966/settings.json b/src/c464393e-7606-406e-8463-a86774590966/settings.json index 16f89db..8c7e61f 100644 --- a/src/c464393e-7606-406e-8463-a86774590966/settings.json +++ b/src/c464393e-7606-406e-8463-a86774590966/settings.json @@ -22,6 +22,6 @@ "namespace": "VDM\\Joomla\\Openai\\Utilities.Response", "description": "The Openai Response\r\n\r\n@since 3.2.0", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git Joomla Component Builder \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", - "head": "use Joomla\\CMS\\Http\\Response as JoomlaResponse;", + "head": "use Joomla\\Http\\Response as JoomlaResponse;", "composer": "" } \ No newline at end of file -- 2.45.2