-
Notifications
You must be signed in to change notification settings - Fork 73
Description
When parsing an XML-File which contains an amount of a ChargesRecord that has "0" as its value, the amount is not being set on the ChargesRecord object.
Example:
<Chrgs>
<Rcrd>
<Amt Ccy="CHF">0</Amt>
...
</Rcd>
</Crgs>
Current behavior
Before setting the amount on the ChargesRecord, the code checks if the amount exists and has a value (here and here). In contrast to other amount values, the "if" statements referenced explicitly expect a "truthy" value. If the value is "0" (string), PHP considers that as "falsy" value and therefore the amount is not set on the ChargesRecord object. For other objects that is not the case (see here).
Expected behavior
If the amount is available, it should also be set on the ChargesRecord object. Otherwise you will get the following error when trying to access the amount via $chargesRecord->getAmount()
:
Typed property Genkgo\Camt\DTO\ChargesRecord::$amount must not be accessed before initialization
Proposed solution
I suggest to simply remove the && (string) $chargesRecord->Amt
part from the "if" statements.