From c155c4e4a6fca9bc97a9676f2e8020207a1a9ea5 Mon Sep 17 00:00:00 2001 From: Ben Borla Date: Sat, 18 Nov 2023 04:52:55 +0800 Subject: [PATCH] chore: code clean-up --- api/src/Service/FruitAggregator.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api/src/Service/FruitAggregator.php b/api/src/Service/FruitAggregator.php index d947d45..da5aa46 100644 --- a/api/src/Service/FruitAggregator.php +++ b/api/src/Service/FruitAggregator.php @@ -49,15 +49,15 @@ public function sync(): self $isNew = true; } - $fruit->setName($item['name']) - ->setFamily($item['family']) - ->setFruitOrder($item['order']) - ->setGenus($item['genus']) - ->setCalories($item['nutritions']['calories']) - ->setFat($item['nutritions']['fat']) - ->setSugar($item['nutritions']['sugar']) - ->setCarbohydrates($item['nutritions']['carbohydrates']) - ->setProtein($item['nutritions']['protein']) + $fruit->setName($item['name'] ?? '') + ->setFamily($item['family'] ?? '') + ->setFruitOrder($item['order'] ?? '') + ->setGenus($item['genus'] ?? '') + ->setCalories($item['nutritions']['calories'] ?? 0.0) + ->setFat($item['nutritions']['fat'] ?? 0.0) + ->setSugar($item['nutritions']['sugar'] ?? 0.0) + ->setCarbohydrates($item['nutritions']['carbohydrates'] ?? 0.0) + ->setProtein($item['nutritions']['protein'] ?? 0.0) ->setSource(Fruit::SOURCE_FETCHED_API); // @INFO: Persist non-existent data