99
1010namespace Lifyzer \Interpreter \Health ;
1111
12+ use Lifyzer \Interpreter \Health \Data \Ingredients ;
1213use Lifyzer \Parser \DbProductColumns as DbColumn ;
1314
1415class HealthStatus
@@ -20,45 +21,6 @@ class HealthStatus
2021 private const DANGER_LEVEL = 5 ;
2122 private const NEUTRAL_LEVEL = 0 ;
2223
23- private const BAD_INGREDIENTS = [
24- 'emulsifier|émulsifiant ' => 3 ,
25- 'additive ' => 3 ,
26- 'stabiliser ' => 2 ,
27- 'flavor enhancer|flavour enhancer ' => 1 ,
28- 'dextrose ' => 2 ,
29- 'palm oil ' => 2.5 , // palm oil is carcinogenic (EFSA source)
30- 'oil ' => 1 ,
31- 'firming agent ' => 0.7 ,
32- 'calcium chloride ' => 0.7 , // https://www.livestrong.com/article/457871-how-does-calcium-chloride-work/
33- 'aspartame|acesulfame ' => 0.4 ,
34- 'syrup|sirop ' => 1.5 ,
35- 'dextrose|maltose|fructose|glucose ' => 1.5 ,
36- 'dextrin|dextrine ' => 1.5 ,
37- 'maltodextrin|maltodextrine ' => 1.5 ,
38- 'sucrose|saccharose ' => 1.5 ,
39- ];
40-
41- private const GOOD_INGREDIENTS = [
42- 'apples ' => 1 , // plural, should be more than one
43- 'broccoli ' => 2.5 ,
44- 'lentil ' => 2 ,
45- 'spinach ' => 1 ,
46- 'celery ' => 0.8 ,
47- 'walnuts ' => 1 , // plural, should be more than one
48- 'chestnuts ' => 1 , // plural, should be more than one
49- 'avocados ' => 1 , // plural, should be more than one
50- 'lemon ' => 1 ,
51- 'garlic ' => 0.5 ,
52- 'antioxidant ' => 2 ,
53- 'sesame ' => 1 ,
54- 'curcuma ' => 1 ,
55- 'spirulina|spiruline ' => 1 ,
56- 'chia ' => 1.2 , // https://draxe.com/chia-seeds-benefits-side-effects/
57- 'kale ' => 0.3 ,
58- 'goji ' => 0.4 , // https://www.nhs.uk/Livewell/superfoods/Pages/are-goji-berries-a-superfood.aspx
59- 'zucchini|courgette ' => 0.4 ,
60- ];
61-
6224 /** @var array */
6325 private $ data ;
6426
@@ -102,7 +64,7 @@ private function areBadIngredients(): bool
10264
10365 private function calculateBadIngredients (): void
10466 {
105- foreach (self ::BAD_INGREDIENTS as $ name => $ level ) {
67+ foreach (Ingredients ::BAD_INGREDIENTS as $ name => $ level ) {
10668 if ($ this ->findInIngredients ($ name )) {
10769 $ this ->dangerLevel += $ level ;
10870 }
@@ -111,7 +73,7 @@ private function calculateBadIngredients(): void
11173
11274 private function calculateGoodIngredients (): void
11375 {
114- foreach (self ::GOOD_INGREDIENTS as $ name => $ level ) {
76+ foreach (Ingredients ::GOOD_INGREDIENTS as $ name => $ level ) {
11577 if ($ this ->findInIngredients ($ name )) {
11678 if ($ this ->dangerLevel === 0 ) {
11779 break ; // Cannot go under zero
0 commit comments