Stable release of v5.0.0-alpha1

First alpha release of Component Builder towards Joomla 5 (very unstable...).
This commit is contained in:
2024-03-09 21:52:51 +02:00
parent 3c91a5cdbb
commit 87cd4305bb
3040 changed files with 296309 additions and 269802 deletions

View File

@@ -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))