From 7a4d7ac70b596ecb96acacf9e2cda2082fdee7b7 Mon Sep 17 00:00:00 2001 From: Matteo Bertoldi Date: Thu, 16 May 2024 11:10:23 +0200 Subject: [PATCH 1/3] =?UTF-8?q?balance=20propriet=C3=A0=20nullable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Models/Balance.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Models/Balance.php b/src/Models/Balance.php index 6b24bb0..0354f4a 100644 --- a/src/Models/Balance.php +++ b/src/Models/Balance.php @@ -6,12 +6,12 @@ class Balance extends GenericModel { /** - * @var string + * @var string|null */ private $Currency; /** - * @var float + * @var float|null */ private $AvailableBalance; @@ -21,7 +21,7 @@ class Balance extends GenericModel { private $AccountingBalance; /** - * @var float + * @var float|null */ private $CreditLine; @@ -34,10 +34,10 @@ class Balance extends GenericModel { protected function hydrateData( stdClass $data ) { $payload = $data->payload; - $this->Currency = (string)$payload->currency; - $this->AvailableBalance = (float)$payload->availableBalance; + $this->Currency = is_null( $payload->currency ) ? null : (string)$payload->currency; + $this->AvailableBalance = is_null( $payload->availableBalance ) ? null : (float)$payload->availableBalance; $this->AccountingBalance = (float)$payload->accountingBalance; - $this->CreditLine = (float)$payload->creditLine; + $this->CreditLine = is_null( $payload->creditLine ) ? null : (float)$payload->creditLine; } From d07ec14b1f401974d90e69e48e7b94b8de502fbe Mon Sep 17 00:00:00 2001 From: Matteo Bertoldi Date: Thu, 16 May 2024 12:39:11 +0200 Subject: [PATCH 2/3] valore nullable saldo contabile --- src/Models/Balance.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/Balance.php b/src/Models/Balance.php index 0354f4a..308d145 100644 --- a/src/Models/Balance.php +++ b/src/Models/Balance.php @@ -16,7 +16,7 @@ class Balance extends GenericModel { private $AvailableBalance; /** - * @var float + * @var float|null */ private $AccountingBalance; @@ -36,7 +36,7 @@ protected function hydrateData( stdClass $data ) { $this->Currency = is_null( $payload->currency ) ? null : (string)$payload->currency; $this->AvailableBalance = is_null( $payload->availableBalance ) ? null : (float)$payload->availableBalance; - $this->AccountingBalance = (float)$payload->accountingBalance; + $this->AccountingBalance = is_null( $payload->accountingBalance ) ? null : (float)$payload->accountingBalance; $this->CreditLine = is_null( $payload->creditLine ) ? null : (float)$payload->creditLine; } From f46b6d45de5c5ddf566969e27be5698bcb1b9c28 Mon Sep 17 00:00:00 2001 From: SVDIGITAL Date: Thu, 16 May 2024 14:04:56 +0200 Subject: [PATCH 3/3] Miglioramento controlli --- src/Models/Balance.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Models/Balance.php b/src/Models/Balance.php index 308d145..70beb42 100644 --- a/src/Models/Balance.php +++ b/src/Models/Balance.php @@ -34,10 +34,10 @@ class Balance extends GenericModel { protected function hydrateData( stdClass $data ) { $payload = $data->payload; - $this->Currency = is_null( $payload->currency ) ? null : (string)$payload->currency; - $this->AvailableBalance = is_null( $payload->availableBalance ) ? null : (float)$payload->availableBalance; - $this->AccountingBalance = is_null( $payload->accountingBalance ) ? null : (float)$payload->accountingBalance; - $this->CreditLine = is_null( $payload->creditLine ) ? null : (float)$payload->creditLine; + $this->Currency = ( !isset( $payload->currency ) or empty( $payload->currency ) ) ? null : (string)$payload->currency; + $this->AvailableBalance = ( !isset( $payload->availableBalance ) or is_null( $payload->availableBalance ) ) ? null : (float)$payload->availableBalance; + $this->AccountingBalance = ( !isset( $payload->accountingBalance ) or is_null( $payload->accountingBalance ) ) ? null : (float)$payload->accountingBalance; + $this->CreditLine = ( !isset( $payload->creditLine ) or is_null( $payload->creditLine ) ) ? null : (float)$payload->creditLine; }