Skip to content

Commit 7436b84

Browse files
committed
Correctly check null values #539
1 parent 4cb798f commit 7436b84

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

app/External/Model/Ingredient.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ public static function fromCSV(array $sourceArray): self
150150
name: $sourceArray['name'],
151151
parentId: null,
152152
strength: isset($sourceArray['strength']) ? floatval($sourceArray['strength']) : 0.0,
153-
description: blank($sourceArray['description']) ? null : $sourceArray['description'],
154-
origin: blank($sourceArray['origin']) ? null : $sourceArray['origin'],
155-
color: blank($sourceArray['color']) ? null : $sourceArray['color'],
153+
description: blank($sourceArray['description'] ?? null) ? null : $sourceArray['description'],
154+
origin: blank($sourceArray['origin'] ?? null) ? null : $sourceArray['origin'],
155+
color: blank($sourceArray['color'] ?? null) ? null : $sourceArray['color'],
156156
createdAt: null,
157157
updatedAt: null,
158158
images: [],
159159
ingredientParts: [],
160160
prices: [],
161161
calculatorId: null,
162-
sugarContent: blank($sourceArray['sugar_g_per_ml']) ? null : $sourceArray['sugar_g_per_ml'],
163-
acidity: blank($sourceArray['acidity']) ? null : $sourceArray['acidity'],
164-
distillery: blank($sourceArray['distillery']) ? null : $sourceArray['distillery'],
165-
units: blank($sourceArray['units']) ? null : new UnitValueObject($sourceArray['units']),
162+
sugarContent: blank($sourceArray['sugar_g_per_ml'] ?? null) ? null : $sourceArray['sugar_g_per_ml'],
163+
acidity: blank($sourceArray['acidity'] ?? null) ? null : $sourceArray['acidity'],
164+
distillery: blank($sourceArray['distillery'] ?? null) ? null : $sourceArray['distillery'],
165+
units: blank($sourceArray['units'] ?? null) ? null : new UnitValueObject($sourceArray['units']),
166166
);
167167
}
168168

0 commit comments

Comments
 (0)