optimize global calls

This commit is contained in:
2026-07-22 16:13:07 +02:00
parent 8c61b69320
commit 90851908b7
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ class Json
public static function sendError($message = 'Bad Request', int $status = 400, ?LoggerInterface $logger = null): void public static function sendError($message = 'Bad Request', int $status = 400, ?LoggerInterface $logger = null): void
{ {
$payload = [ $payload = [
'error' => is_array($message) ? $message : ['message' => $message] 'error' => \is_array($message) ? $message : ['message' => $message]
]; ];
if ($logger) { if ($logger) {
+4 -4
View File
@@ -40,7 +40,7 @@ class ElixFormsApiClient
$payload = $this->getJson($url, $authToken, $username, 'LookupByStatus'); $payload = $this->getJson($url, $authToken, $username, 'LookupByStatus');
$requests = $payload['value']['requests'] ?? []; $requests = $payload['value']['requests'] ?? [];
if (!is_array($requests)) { if (!\is_array($requests)) {
throw new ElixFormsException('Risposta LookupByStatus non valida: requests deve essere un array.'); throw new ElixFormsException('Risposta LookupByStatus non valida: requests deve essere un array.');
} }
@@ -74,7 +74,7 @@ class ElixFormsApiClient
$payload = $this->getJson($url, $authToken, $username, 'GetExportTags'); $payload = $this->getJson($url, $authToken, $username, 'GetExportTags');
$exportTags = $payload['value']['exportTags'] ?? []; $exportTags = $payload['value']['exportTags'] ?? [];
if (!is_array($exportTags)) { if (!\is_array($exportTags)) {
throw new ElixFormsException('Risposta GetExportTags non valida: exportTags deve essere un array.'); throw new ElixFormsException('Risposta GetExportTags non valida: exportTags deve essere un array.');
} }
@@ -105,12 +105,12 @@ class ElixFormsApiClient
$payload = $response['json'] ?? null; $payload = $response['json'] ?? null;
$jsonError = JSON_ERROR_NONE; $jsonError = JSON_ERROR_NONE;
if (!is_array($payload) && isset($response['body']) && is_string($response['body'])) { if (!\is_array($payload) && isset($response['body']) && \is_string($response['body'])) {
$payload = json_decode($response['body'], true); $payload = json_decode($response['body'], true);
$jsonError = json_last_error(); $jsonError = json_last_error();
} }
if (!is_array($payload) || $jsonError !== JSON_ERROR_NONE) { if (!\is_array($payload) || $jsonError !== JSON_ERROR_NONE) {
throw new ElixFormsException(\sprintf( throw new ElixFormsException(\sprintf(
'Risposta non valida da %s: atteso JSON.', 'Risposta non valida da %s: atteso JSON.',
$operation $operation