id = new IncoCompositionId('67890'); $this->idInco = new IncoId('12345'); $this->identification = new Identification('Poulet RĂ´ti Test', '12345', 'LDC'); $energyValues = new EnergyValues('100g', '750', '180'); $this->energy = new Energy($energyValues, $energyValues); $zeroNutrient = new NutrientValue('0'); $this->referenceMacronutrients = new ReferenceMacronutrients($zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient); $this->portionMacronutrients = new PortionMacronutrients($zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient, $zeroNutrient); $fnAmount = new FruitAndNutAmount(); $zeroPercent = new PercentageValue('0'); $this->freshProduceAndNuts = new FreshProduceAndNuts($fnAmount, $fnAmount, $zeroPercent, $zeroPercent); $this->referenceIntakes = new ReferenceIntakes($zeroPercent, $zeroPercent, $zeroPercent, $zeroPercent, $zeroPercent, $zeroPercent, $zeroPercent, $zeroPercent, '100g'); $this->nutriScore = new NutriScore('0', '0', 'A'); $this->nutriScorePoints = new NutriScorePoints('0', '0', '0', '0', '0', '0', '0'); $this->minerals = new Minerals('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $this->vitamins = new Vitamins('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $this->carbohydratesDetail = new CarbohydratesDetail('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $this->fattyAcids = new FattyAcids('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $this->aminoAcids = new AminoAcids('0', '0', '0'); $this->specialCompounds = new SpecialCompounds('0', '0', '0', '0'); } public static function create(): self { return new self(); } public function withId(string | IncoCompositionId $id): self { $this->id = is_string($id) ? new IncoCompositionId($id) : $id; return $this; } public function withIdInco(string | IncoId $idInco): self { $this->idInco = is_string($idInco) ? new IncoId($idInco) : $idInco; return $this; } public function withIdentification(string $name, ?string $number = null, ?string $source = null): self { $this->identification = new Identification( name: $name, number: $number ?? $this->idInco->value, source: $source ?? 'Arcadia', ); return $this; } public function withNutriScore(string $grade, string $score = '0', string $negativeComponent = '0'): self { $this->nutriScore = new NutriScore($negativeComponent, $score, $grade); return $this; } public function build(): IncoComposition { return IncoComposition::hydrate( id: $this->id, idInco: $this->idInco, identification: $this->identification, energy: $this->energy, referenceMacronutrients: $this->referenceMacronutrients, portionMacronutrients: $this->portionMacronutrients, freshProduceAndNuts: $this->freshProduceAndNuts, referenceIntakes: $this->referenceIntakes, nutriScore: $this->nutriScore, nutriScorePoints: $this->nutriScorePoints, minerals: $this->minerals, vitamins: $this->vitamins, carbohydratesDetail: $this->carbohydratesDetail, fattyAcids: $this->fattyAcids, aminoAcids: $this->aminoAcids, specialCompounds: $this->specialCompounds, ); } public function buildOutput(): IncoCompositionOutput { $entity = $this->build(); return new IncoCompositionOutput( id: $entity->id(), idInco: $entity->idInco, identification: $entity->identification, energy: $entity->energy, referenceMacronutrients: $entity->referenceMacronutrients, portionMacronutrients: $entity->portionMacronutrients, freshProduceAndNuts: $entity->freshProduceAndNuts, referenceIntakes: $entity->referenceIntakes, nutriScore: $entity->nutriScore, nutriScorePoints: $entity->nutriScorePoints, minerals: $entity->minerals, vitamins: $entity->vitamins, carbohydratesDetail: $entity->carbohydratesDetail, fattyAcids: $entity->fattyAcids, aminoAcids: $entity->aminoAcids, specialCompounds: $entity->specialCompounds, ); } }