be more defensive about array index

This commit is contained in:
Dennis Eichhorn 2022-12-24 23:58:00 +01:00
parent 88938b7fd1
commit 092c9b9f29

View File

@ -115,7 +115,12 @@ final class Currency
self::$ecbCurrencies = [];
foreach ($node as $key => $value) {
self::$ecbCurrencies[\strtoupper((string) $value->attributes()['currency'])] = (float) $value->attributes()['rate'];
/** @var null|array<string, string|int|float> $attributes */
if (($attributes = $value->attributes()) === null) {
continue;
}
self::$ecbCurrencies[\strtoupper((string) ($attributes['currency']))] = (float) ($attributes['rate']);
}
} catch (\Throwable $t) {
self::$ecbCurrencies = []; // @codeCoverageIgnore