mirror of https://github.com/kcal-app/kcal.git
Assume empty "from unit" is serving
This commit is contained in:
parent
4249457769
commit
3628ab1f51
|
@ -30,7 +30,7 @@ class Nutrients
|
||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($food->serving_unit === $fromUnit) {
|
if (empty($fromUnit) || $food->serving_unit === $fromUnit) {
|
||||||
$multiplier = 1;
|
$multiplier = 1;
|
||||||
}
|
}
|
||||||
elseif ($fromUnit === 'tsp') {
|
elseif ($fromUnit === 'tsp') {
|
||||||
|
@ -52,7 +52,7 @@ class Nutrients
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new \DomainException("Unhandled unit combination: {$fromUnit}, {$food->serving_unit}");
|
throw new \DomainException("Unhandled unit combination: {$fromUnit}, {$food->serving_unit} ({$food->name})");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $multiplier / $food->serving_size * $amount;
|
return $multiplier / $food->serving_size * $amount;
|
||||||
|
|
Loading…
Reference in New Issue