From ef30723ea9dc610f7113e7b1e644f5b4312a749b Mon Sep 17 00:00:00 2001 From: aB0t Date: Sat, 27 Jan 2024 09:09:52 +0200 Subject: [PATCH] update 2024-01-27 --- .../code.php | 26 +++++++++---------- .../code.power | 23 ++++++++-------- .../settings.json | 2 +- .../code.php | 4 +-- .../code.power | 4 +-- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.php b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.php index 4b3574e..ed98fff 100644 --- a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.php +++ b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Gitea\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])) @@ -86,24 +86,23 @@ 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)) { - $body = json_decode((string) $response->body); + $body = json_decode((string) $body); if (isset($body->content_base64)) { $body->content = base64_decode((string) $body->content_base64); } - - return $body; } - return $response->body; + return $body; } return $default; @@ -117,7 +116,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)) @@ -140,7 +139,6 @@ final class Response } return ''; - } - + } } diff --git a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.power b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.power index eb1d40d..93a7b6c 100644 --- a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/code.power +++ b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/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])) @@ -60,24 +60,23 @@ * @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)) { - $body = json_decode((string) $response->body); + $body = json_decode((string) $body); if (isset($body->content_base64)) { $body->content = base64_decode((string) $body->content_base64); } - - return $body; } - return $response->body; + return $body; } return $default; @@ -91,7 +90,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)) @@ -114,4 +113,4 @@ } return ''; - } + } \ No newline at end of file diff --git a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/settings.json b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/settings.json index 7ed384f..75b50a4 100644 --- a/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/settings.json +++ b/src/19eb68d7-1e19-4d14-a0ef-70d719c45e80/settings.json @@ -22,6 +22,6 @@ "namespace": "VDM\\Joomla\\Gitea\\Utilities.Response", "description": "The Gitea 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 diff --git a/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.php b/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.php index 6c5b3c6..ea65e1c 100644 --- a/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.php +++ b/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.php @@ -52,7 +52,7 @@ final class Http extends JoomlaHttp // add the token if given if (is_string($token)) { - $config['headers']['Authorization'] = 'token ' . $token; + $config['headers']['Authorization'] = $token; $this->_token_ = $token; } @@ -78,7 +78,7 @@ final class Http extends JoomlaHttp ); // add the token - $headers['Authorization'] = 'token ' . $token; + $headers['Authorization'] = $token; $this->_token_ = $token; $this->setOption('headers', $headers); diff --git a/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.power b/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.power index 0e1e9af..238f687 100644 --- a/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.power +++ b/src/ce40b3d2-226c-4a64-b116-c19455822be1/code.power @@ -27,7 +27,7 @@ // add the token if given if (is_string($token)) { - $config['headers']['Authorization'] = 'token ' . $token; + $config['headers']['Authorization'] = $token; $this->_token_ = $token; } @@ -53,7 +53,7 @@ ); // add the token - $headers['Authorization'] = 'token ' . $token; + $headers['Authorization'] = $token; $this->_token_ = $token; $this->setOption('headers', $headers);