From ab7d71bb5f77b71dc43660cedb72b6b083624aa7 Mon Sep 17 00:00:00 2001 From: Sebastian Volland Date: Sun, 28 Apr 2024 18:45:10 +0200 Subject: [PATCH 1/2] Type fix: Statement::creditDebit to be null --- lib/Fhp/Model/StatementOfAccount/Statement.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Fhp/Model/StatementOfAccount/Statement.php b/lib/Fhp/Model/StatementOfAccount/Statement.php index 63c3f114..32237a50 100644 --- a/lib/Fhp/Model/StatementOfAccount/Statement.php +++ b/lib/Fhp/Model/StatementOfAccount/Statement.php @@ -23,9 +23,9 @@ class Statement protected $endBalance = null; /** - * @var string + * @var string|null */ - protected $creditDebit; + protected $creditDebit = null; /** * @var \DateTime|null @@ -91,7 +91,7 @@ public function setEndBalance(float $endBalance) /** * Get creditDebit */ - public function getCreditDebit(): string + public function getCreditDebit(): ?string { return $this->creditDebit; } From 63373e16f0ae16d5cdcb9c103aff987e76a9abfd Mon Sep 17 00:00:00 2001 From: Sebastian Volland Date: Sun, 28 Apr 2024 19:00:57 +0200 Subject: [PATCH 2/2] Fix "Undefined array key" warnings --- .../Model/StatementOfAccount/StatementOfAccount.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Fhp/Model/StatementOfAccount/StatementOfAccount.php b/lib/Fhp/Model/StatementOfAccount/StatementOfAccount.php index ba1b3b39..dd0b0a35 100644 --- a/lib/Fhp/Model/StatementOfAccount/StatementOfAccount.php +++ b/lib/Fhp/Model/StatementOfAccount/StatementOfAccount.php @@ -73,11 +73,15 @@ public static function fromMT940Array(array $array): StatementOfAccount } else { $statementModel = new Statement(); $statementModel->setDate(static::parseDate($date)); - $statementModel->setStartBalance((float) $statement['start_balance']['amount']); - if(isset($statement['end_balance'])){ + if (isset($statement['start_balance']['amount'])) { + $statementModel->setStartBalance((float) $statement['start_balance']['amount']); + } + if (isset($statement['end_balance'])) { $statementModel->setEndBalance((float) $statement['end_balance']['amount']); } - $statementModel->setCreditDebit($statement['start_balance']['credit_debit']); + if (isset($statement['start_balance']['credit_debit'])) { + $statementModel->setCreditDebit($statement['start_balance']['credit_debit']); + } $result->statements[] = $statementModel; }