protected function setCiqualValues(Ingredient $ingredient, array $ciqualIngredient) { $ingredient->setName($ciqualIngredient['ORIGFDNM']); $ingredient->setCiqualcode(intval($ciqualIngredient['ORIGFDCD'])); $ingredient->setEnergyKcal(intval($ciqualIngredient['328 Energie, Règlement UE N° 1169/2011 (kcal/100g)'])); $ingredient->setFat($this->strToFloat($ciqualIngredient['40000 Lipides (g/100g)'])); $ingredient->setSaturatedFat($this->strToFloat($ciqualIngredient['40302 AG saturés (g/100g)'])); $ingredient->setCarbohydrate($this->strToFloat($ciqualIngredient['31000 Glucides (g/100g)'])); $ingredient->setSugars($this->strToFloat($ciqualIngredient['32000 Sucres (g/100g)'])); $ingredient->setFiber($this->strToFloat($ciqualIngredient['34100 Fibres (g/100g)'])); $ingredient->setProteins($this->strToFloat($ciqualIngredient['25000 Protéines (g/100g)'])); $ingredient->setSalt($this->strToFloat($ciqualIngredient['10110 Sodium (mg/100g)']) * 2.5 / 1000); $ingredient->setSodium($this->strToFloat($ciqualIngredient['10110 Sodium (mg/100g)']) / 1000); }
/** ************************************************************************ * Set to $ingredient the values of the $openfoodfactIngredient * @param Ingredient $ingredient * @param array $openfoodfactIngredient **************************************************************************/ protected function setOpenfoodfactValues(Ingredient $ingredient, array $openfoodfactIngredient) { $ingredient->setName($openfoodfactIngredient['product_name'] . ' (' . $openfoodfactIngredient['brands'] . ')'); $ingredient->setBarcode($openfoodfactIngredient['code']); $ingredient->setEnergyKcal(intval($openfoodfactIngredient['energy_100g']) / 4.184); // 'energy_100g' is in kj $ingredient->setFat($this->strToFloat($openfoodfactIngredient['fat_100g'])); $ingredient->setSaturatedFat($this->strToFloat($openfoodfactIngredient['saturated-fat_100g'])); $ingredient->setCarbohydrate($this->strToFloat($openfoodfactIngredient['carbohydrates_100g'])); $ingredient->setSugars($this->strToFloat($openfoodfactIngredient['sugars_100g'])); $ingredient->setFiber($this->strToFloat($openfoodfactIngredient['fiber_100g'])); $ingredient->setProteins($this->strToFloat($openfoodfactIngredient['proteins_100g'])); $ingredient->setSalt($this->strToFloat($openfoodfactIngredient['salt_100g'])); $ingredient->setSodium($this->strToFloat($openfoodfactIngredient['sodium_100g'])); }