*/ private array $allergens = []; private IncoBrand $brand; private bool $isSeasonal = false; private ?IncoWeight $weight = null; private ?Nutriscore $nutriscore = null; private ?StorageCondition $storageCondition = null; /** @var array */ private array $additives = []; private ?IncoCompositionId $compo = null; private ?\DateTimeInterface $createdAt = null; private ?\DateTimeInterface $updatedAt = null; public function __construct() { $this->id = new IncoId('12345'); $this->name = 'Poulet Rôti 1kg'; $this->label = 'Poulet Rôti Classe A'; $this->description = 'Poulet prêt à cuire'; $this->allegations = new Allegations(['Volaille française']); $this->sellArguments = 'Délicieux et tendre'; $this->preparationAdvices = 'Cuire 45min à 180°C'; $this->ingredients = new Ingredients(['Ingrédients' => ['Viande de dinde (66%)']]); $this->brand = new IncoBrand(new BrandName('Le Gaulois'), new BrandCode('LGL01'), new ArcadiaId('504')); $this->isSeasonal = false; $this->weight = null; $this->nutriscore = null; $this->storageCondition = null; $this->additives = []; $this->compo = null; $this->createdAt = new \DateTimeImmutable('2024-01-01 00:00:00'); $this->updatedAt = null; } public static function create(): self { return new self(); } public function withId(string | IncoId $id): self { $this->id = is_string($id) ? new IncoId($id) : $id; return $this; } public function withName(string $name): self { $this->name = $name; return $this; } public function withLabel(string $label): self { $this->label = $label; return $this; } public function withDescription(string $description): self { $this->description = $description; return $this; } public function withBrand(IncoBrand | string $brand, ?string $code = null, ?string $arcadiaId = null): self { if (is_string($brand)) { $this->brand = new IncoBrand( name: new BrandName($brand), code: new BrandCode($code ?? 'LGL01'), arcadiaBrandCode: new ArcadiaId($arcadiaId ?? '1'), ); } else { $this->brand = $brand; } return $this; } public function withNutriscore(?string $grade): self { $this->nutriscore = $grade !== null ? new Nutriscore($grade) : null; return $this; } public function withCompo(?string $compoId): self { $this->compo = $compoId !== null ? new IncoCompositionId($compoId) : null; return $this; } public function withSeasonal(bool $isSeasonal): self { $this->isSeasonal = $isSeasonal; return $this; } public function withDates(?\DateTimeInterface $createdAt, ?\DateTimeInterface $updatedAt = null): self { $this->createdAt = $createdAt; $this->updatedAt = $updatedAt ?? $createdAt; return $this; } public function build(): IncoSheet { return IncoSheet::hydrate( id: $this->id, name: $this->name, label: $this->label, description: $this->description, allegations: $this->allegations, sellArguments: $this->sellArguments, preparationAdvices: $this->preparationAdvices, tips: $this->tips, sellFamilly: $this->sellFamilly, ingredients: $this->ingredients, portions: $this->portions, allergens: $this->allergens, brand: $this->brand, isSeasonal: $this->isSeasonal, weight: $this->weight, nutriscore: $this->nutriscore, storageCondition: $this->storageCondition, additives: $this->additives, compo: $this->compo, createdAt: $this->createdAt, updatedAt: $this->updatedAt, ); } public function buildOutput(): IncoSheetOutput { $entity = $this->build(); return new IncoSheetOutput( id: $entity->id, name: $entity->name, label: $entity->label, description: $entity->description, allegations: $entity->allegations, sellArguments: $entity->sellArguments, preparationAdvices: $entity->preparationAdvices, tips: $entity->tips, sellFamilly: $entity->sellFamilly, ingredients: $entity->ingredients, portions: $entity->portions, allergens: $entity->allergens, brand: $entity->brand, isSeasonal: $entity->isSeasonal, weight: $entity->weight, nutriscore: $entity->nutriscore, storageCondition: $entity->storageCondition, additives: $entity->additives, compo: $entity->compo, createdAt: $entity->createdAt, updatedAt: $entity->updatedAt, ); } }